Re: Latest patches break one of our unit-test, related to RLS

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dominique Devienne <ddevienne(at)gmail(dot)com>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-general(at)postgresql(dot)org
Subject: Re: Latest patches break one of our unit-test, related to RLS
Date: 2025-09-12 14:07:06
Message-ID: 2109533.1757686026@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dominique Devienne <ddevienne(at)gmail(dot)com> 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=# 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=0.00..0.05 rows=1 width=32)
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=# 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=0.00..0.05 rows=1 width=32)
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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dominique Devienne 2025-09-12 14:28:36 Re: Latest patches break one of our unit-test, related to RLS
Previous Message Dominique Devienne 2025-09-12 13:57:45 Re: Latest patches break one of our unit-test, related to RLS