diff options
author | Michael Paquier <michael@paquier.xyz> | 2025-05-28 08:58:40 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2025-05-28 08:58:40 +0900 |
commit | d46911e584d48ee01d5bf75699a77fbf635c865d (patch) | |
tree | 3e7e39095ad21a728f7bb0667fe48c1249d3c05b /contrib/intarray/_intbig_gist.c | |
parent | 3e782ca32225e5d5219251a5a3c06698c1e824f8 (diff) | |
download | postgresql-d46911e584d48ee01d5bf75699a77fbf635c865d.tar.gz postgresql-d46911e584d48ee01d5bf75699a77fbf635c865d.zip |
Fix conversion of SIMILAR TO regexes for character classes
The code that translates SIMILAR TO pattern matching expressions to
POSIX-style regular expressions did not consider that square brackets
can be nested. For example, in an expression like [[:alpha:]%_], the
logic replaced the placeholders '_' and '%' but it should not.
This commit fixes the conversion logic by tracking the nesting level of
square brackets marking character class areas, while considering that
in expressions like []] or [^]] the first closing square bracket is a
regular character. Multiple tests are added to show how the conversions
should or should not apply applied while in a character class area, with
specific cases added for all the characters converted outside character
classes like an opening parenthesis '(', dollar sign '$', etc.
Author: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/16ab039d1af455652bdf4173402ddda145f2c73b.camel@cybertec.at
Backpatch-through: 13
Diffstat (limited to 'contrib/intarray/_intbig_gist.c')
0 files changed, 0 insertions, 0 deletions