Re: SIMILAR TO expressions translate wildcards where they shouldn't
Laurenz Albe <laurenz.albe@cybertec.at>
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>, pgsql-bugs@lists.postgresql.org
Date: 2025-05-27T21:39:02Z
Lists: pgsql-bugs
On Tue, 2025-05-27 at 10:54 -0400, Tom Lane wrote: > Laurenz Albe <laurenz.albe@cybertec.at> writes: > > On Tue, 2025-05-27 at 14:57 +0900, Michael Paquier wrote: > > > With some tweaks and the tests reworked, I am finishing with the > > > reviewed version attached. What do you think? > > > Thank you; I think that is good to go. > > Code changes look good, but I think the test cases are too cute: > > +EXPLAIN (VERBOSE, COSTS OFF) SELECT (SELECT '') SIMILAR TO '_[_[:alpha:]_]_'; > + QUERY PLAN > +--------------------------------------------------------------- > + Result > + Output: ((InitPlan 1).col1 ~ '^(?:.[_[:alpha:]_].)$'::text) > + InitPlan 1 > + -> Result > + Output: ''::text > +(5 rows) > > This will break whenever somebody decides it's worth optimizing > a sub-select that looks like that. I'd suggest following the > pattern > > explain (costs off) select * from text_tbl where f1 similar to 'z'; > QUERY PLAN > ---------------------------------- > Seq Scan on text_tbl > Filter: (f1 ~ '^(?:z)$'::text) > (2 rows) > > which is both less noisy and less likely to change in future. That's a good point. I originally considered EXPLAIN (GENERIC_PLAN), but that would only backpatch so far. Yours, Laurenz Albe
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Adjust regex for test with opening parenthesis in character classes
- 31ee5ec698ed 13.22 landed
- 0c09922c04ea 14.19 landed
- 4dc642e75f1c 15.14 landed
- 52d08620e48c 16.10 landed
- a3c6d92f3cb3 17.6 landed
- 4fbb46f61271 18.0 landed
-
Fix conversion of SIMILAR TO regexes for character classes
- 9481d1614c2a 13.22 landed
- 1fe15d25e65c 14.19 landed
- b3e99115e44c 15.14 landed
- e9e535d61120 16.10 landed
- e3ffc3e91d04 17.6 landed
- d46911e584d4 18.0 landed