Re: Latest patches break one of our unit-test, related to RLS
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Dominique Devienne <ddevienne@gmail.com>
Cc: Laurenz Albe <laurenz.albe@cybertec.at>, pgsql-general@postgresql.org
Date: 2025-09-12T13:53:34Z
Lists: pgsql-general
On Fri, Sep 12, 2025 at 9:35 PM Dominique Devienne <ddevienne@gmail.com> wrote:
>
> On Fri, Sep 12, 2025 at 3:29 PM Dominique Devienne <ddevienne@gmail.com> wrote:
> > On Fri, Sep 12, 2025 at 3:24 PM Dominique Devienne <ddevienne@gmail.com> wrote:
> > > On Fri, Sep 12, 2025 at 3:11 PM Dominique Devienne <ddevienne@gmail.com> wrote:
> >
> > > So I don't see how my `... where v similar to 'foo[\d\w]_%'` is incorrect.
> > > So again, is this a bug / regression or not? Thanks, --DD
> >
> > If I use (x|y) instead of [xy] it seems to behave correctly.
> > Whether x is the full-length POSIX class, or the shorthand notation.
> > This DOES look like a bug, no? I've done regexes for a long time,
> > and these two forms should be equivalent IMHO. --DD
> >
> > postgres=# show server_version;
> > server_version
> > ----------------
> > 18rc1
> > (1 row)
> >
> >
> > postgres=# with t(v) as (values ('foo:bar'), ('foo/bar'), ('foo0bar'))
> > select v from t where v similar to 'foo[\d\w]_%';
> > v
> > ---
> > (0 rows)
> >
> >
> > postgres=# with t(v) as (values ('foo:bar'), ('foo/bar'), ('foo0bar'))
> > select v from t where v similar to 'foo[[[:digit:]][[:word:]]]_%';
> > v
> > ---
> > (0 rows)
> >
The above two examples are the same, per
(Table 9.21. Regular Expression Class-Shorthand Escapes)
https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-SIMILARTO-REGEXP
my guess why 'foo0bar' will fail for 'foo[[[:digit:]][[:word:]]]_%';
1. process character 0, it does meet [[:digits]] character class.
2. process character b, it does not meet [[:digits]], then fails,
it won't check again whether character b is satisfied with [[:word:]] or not.
Commits
-
Amend recent fix for SIMILAR TO regex conversion.
- f75ff1b141a5 14.20 landed
- e09adb5b9fc9 17.7 landed
- cdf7feb96562 19 (unreleased) landed
- 9fd531534b64 15.15 landed
- 802308693f2f 18.0 landed
- 308773617d2d 13.23 landed
- 281ad4ed11d2 16.11 landed
-
Fix conversion of SIMILAR TO regexes for character classes
- e3ffc3e91d04 17.6 cited