Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ux4Qj-00AS13-PN for pgsql-general@arkaria.postgresql.org; Fri, 12 Sep 2025 14:07:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ux4Qh-001aOT-K8 for pgsql-general@arkaria.postgresql.org; Fri, 12 Sep 2025 14:07:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ux4Qh-001aOL-94 for pgsql-general@lists.postgresql.org; Fri, 12 Sep 2025 14:07:12 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ux4Qd-000QWw-37 for pgsql-general@postgresql.org; Fri, 12 Sep 2025 14:07:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 58CE76P12109534; Fri, 12 Sep 2025 10:07:06 -0400 From: Tom Lane To: Dominique Devienne cc: Laurenz Albe , pgsql-general@postgresql.org Subject: Re: Latest patches break one of our unit-test, related to RLS In-reply-to: References: <77a63548783dd4007ee479a4c5ed300629aaa776.camel@cybertec.at> Comments: In-reply-to Dominique Devienne message dated "Fri, 12 Sep 2025 15:34:58 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2109532.1757686026.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 12 Sep 2025 10:07:06 -0400 Message-ID: <2109533.1757686026@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dominique Devienne writes: >> This DOES look like a bug, no? I've done regexes for a long time, >> and these two forms should be equivalent IMHO. --DD Yeah, I agree it's busted. You can use EXPLAIN VERBOSE to see the translated-to-POSIX pattern, and it's wrong: regression=3D# explain verbose with t(v) as (values ('foo:bar'), ('foo/bar= '), ('foo0bar')) = select v from t where v similar to 'foo[\d\w]_%'; QUERY PLAN = -------------------------------------------------------------- Values Scan on "*VALUES*" (cost=3D0.00..0.05 rows=3D1 width=3D32) Output: "*VALUES*".column1 Filter: ("*VALUES*".column1 ~ '^(?:foo[\d\w]_%)$'::text) (3 rows) The _ and % are not getting converted to their POSIX equivalents ("." and ".*"). Your other example still does that correctly: regression=3D# explain verbose with t(v) as (values ('foo:bar'), ('foo/bar= '), ('foo0bar')) select v from t where v similar to 'foo[0-9a-zA-Z]_%'; QUERY PLAN = ------------------------------------------------------------------ Values Scan on "*VALUES*" (cost=3D0.00..0.05 rows=3D1 width=3D32) Output: "*VALUES*".column1 Filter: ("*VALUES*".column1 ~ '^(?:foo[0-9a-zA-Z]..*)$'::text) (3 rows) So e3ffc3e91 was at least one brick shy of a load. regards, tom lane