pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Amend recent fix for SIMILAR TO regex conversion. 7+ messages / 1 participants [nested] [flat]
* pgsql: Amend recent fix for SIMILAR TO regex conversion. @ 2025-09-13 20:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-13 20:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Amend recent fix for SIMILAR TO regex conversion. Commit e3ffc3e91 fixed the translation of character classes in SIMILAR TO regular expressions. Unfortunately the fix broke a corner case: if there is an escape character right after the opening bracket (for example in "[\q]"), a closing bracket right after the escape sequence would not be seen as closing the character class. There were two more oversights: a backslash or a nested opening bracket right at the beginning of a character class should remove the special meaning from any following caret or closing bracket. This bug suggests that this code needs to be more readable, so also rename the variables "charclass_depth" and "charclass_start" to something more meaningful, rewrite an "if" cascade to be more consistent, and improve the commentary. Reported-by: Dominique Devienne <ddevienne@gmail.com> Reported-by: Stephan Springl <springl-psql@bfw-online.de> Author: Laurenz Albe <laurenz.albe@cybertec.at> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAFCRh-8NwJd0jq6P=R3qhHyqU7hw0BTor3W0SvUcii24et+zAw@mail.gmail.com Backpatch-through: 13 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/e09adb5b9fc9dec27c7ff9e9592723d7d8098b03 Modified Files -------------- src/backend/utils/adt/regexp.c | 97 +++++++++++++++++++++++++---------- src/test/regress/expected/strings.out | 9 ++++ src/test/regress/sql/strings.sql | 3 ++ 3 files changed, 82 insertions(+), 27 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Amend recent fix for SIMILAR TO regex conversion. @ 2025-09-13 20:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-13 20:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Amend recent fix for SIMILAR TO regex conversion. Commit e3ffc3e91 fixed the translation of character classes in SIMILAR TO regular expressions. Unfortunately the fix broke a corner case: if there is an escape character right after the opening bracket (for example in "[\q]"), a closing bracket right after the escape sequence would not be seen as closing the character class. There were two more oversights: a backslash or a nested opening bracket right at the beginning of a character class should remove the special meaning from any following caret or closing bracket. This bug suggests that this code needs to be more readable, so also rename the variables "charclass_depth" and "charclass_start" to something more meaningful, rewrite an "if" cascade to be more consistent, and improve the commentary. Reported-by: Dominique Devienne <ddevienne@gmail.com> Reported-by: Stephan Springl <springl-psql@bfw-online.de> Author: Laurenz Albe <laurenz.albe@cybertec.at> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAFCRh-8NwJd0jq6P=R3qhHyqU7hw0BTor3W0SvUcii24et+zAw@mail.gmail.com Backpatch-through: 13 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9fd531534b646a62e0a99be4ca81c2f735a83293 Modified Files -------------- src/backend/utils/adt/regexp.c | 97 +++++++++++++++++++++++++---------- src/test/regress/expected/strings.out | 9 ++++ src/test/regress/sql/strings.sql | 3 ++ 3 files changed, 82 insertions(+), 27 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Amend recent fix for SIMILAR TO regex conversion. @ 2025-09-13 20:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-13 20:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Amend recent fix for SIMILAR TO regex conversion. Commit e3ffc3e91 fixed the translation of character classes in SIMILAR TO regular expressions. Unfortunately the fix broke a corner case: if there is an escape character right after the opening bracket (for example in "[\q]"), a closing bracket right after the escape sequence would not be seen as closing the character class. There were two more oversights: a backslash or a nested opening bracket right at the beginning of a character class should remove the special meaning from any following caret or closing bracket. This bug suggests that this code needs to be more readable, so also rename the variables "charclass_depth" and "charclass_start" to something more meaningful, rewrite an "if" cascade to be more consistent, and improve the commentary. Reported-by: Dominique Devienne <ddevienne@gmail.com> Reported-by: Stephan Springl <springl-psql@bfw-online.de> Author: Laurenz Albe <laurenz.albe@cybertec.at> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAFCRh-8NwJd0jq6P=R3qhHyqU7hw0BTor3W0SvUcii24et+zAw@mail.gmail.com Backpatch-through: 13 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/cdf7feb96562071f15ceb070272d7e84246d943d Modified Files -------------- src/backend/utils/adt/regexp.c | 97 +++++++++++++++++++++++++---------- src/test/regress/expected/strings.out | 9 ++++ src/test/regress/sql/strings.sql | 3 ++ 3 files changed, 82 insertions(+), 27 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Amend recent fix for SIMILAR TO regex conversion. @ 2025-09-13 20:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-13 20:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Amend recent fix for SIMILAR TO regex conversion. Commit e3ffc3e91 fixed the translation of character classes in SIMILAR TO regular expressions. Unfortunately the fix broke a corner case: if there is an escape character right after the opening bracket (for example in "[\q]"), a closing bracket right after the escape sequence would not be seen as closing the character class. There were two more oversights: a backslash or a nested opening bracket right at the beginning of a character class should remove the special meaning from any following caret or closing bracket. This bug suggests that this code needs to be more readable, so also rename the variables "charclass_depth" and "charclass_start" to something more meaningful, rewrite an "if" cascade to be more consistent, and improve the commentary. Reported-by: Dominique Devienne <ddevienne@gmail.com> Reported-by: Stephan Springl <springl-psql@bfw-online.de> Author: Laurenz Albe <laurenz.albe@cybertec.at> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAFCRh-8NwJd0jq6P=R3qhHyqU7hw0BTor3W0SvUcii24et+zAw@mail.gmail.com Backpatch-through: 13 Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f75ff1b141a5ceccfc6292af5e94238c360f89e9 Modified Files -------------- src/backend/utils/adt/regexp.c | 97 +++++++++++++++++++++++++---------- src/test/regress/expected/strings.out | 9 ++++ src/test/regress/sql/strings.sql | 3 ++ 3 files changed, 82 insertions(+), 27 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Amend recent fix for SIMILAR TO regex conversion. @ 2025-09-13 20:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-13 20:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Amend recent fix for SIMILAR TO regex conversion. Commit e3ffc3e91 fixed the translation of character classes in SIMILAR TO regular expressions. Unfortunately the fix broke a corner case: if there is an escape character right after the opening bracket (for example in "[\q]"), a closing bracket right after the escape sequence would not be seen as closing the character class. There were two more oversights: a backslash or a nested opening bracket right at the beginning of a character class should remove the special meaning from any following caret or closing bracket. This bug suggests that this code needs to be more readable, so also rename the variables "charclass_depth" and "charclass_start" to something more meaningful, rewrite an "if" cascade to be more consistent, and improve the commentary. Reported-by: Dominique Devienne <ddevienne@gmail.com> Reported-by: Stephan Springl <springl-psql@bfw-online.de> Author: Laurenz Albe <laurenz.albe@cybertec.at> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAFCRh-8NwJd0jq6P=R3qhHyqU7hw0BTor3W0SvUcii24et+zAw@mail.gmail.com Backpatch-through: 13 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/802308693f2f55704751657986abdc81f76ee4cf Modified Files -------------- src/backend/utils/adt/regexp.c | 97 +++++++++++++++++++++++++---------- src/test/regress/expected/strings.out | 9 ++++ src/test/regress/sql/strings.sql | 3 ++ 3 files changed, 82 insertions(+), 27 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Amend recent fix for SIMILAR TO regex conversion. @ 2025-09-13 20:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-13 20:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Amend recent fix for SIMILAR TO regex conversion. Commit e3ffc3e91 fixed the translation of character classes in SIMILAR TO regular expressions. Unfortunately the fix broke a corner case: if there is an escape character right after the opening bracket (for example in "[\q]"), a closing bracket right after the escape sequence would not be seen as closing the character class. There were two more oversights: a backslash or a nested opening bracket right at the beginning of a character class should remove the special meaning from any following caret or closing bracket. This bug suggests that this code needs to be more readable, so also rename the variables "charclass_depth" and "charclass_start" to something more meaningful, rewrite an "if" cascade to be more consistent, and improve the commentary. Reported-by: Dominique Devienne <ddevienne@gmail.com> Reported-by: Stephan Springl <springl-psql@bfw-online.de> Author: Laurenz Albe <laurenz.albe@cybertec.at> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAFCRh-8NwJd0jq6P=R3qhHyqU7hw0BTor3W0SvUcii24et+zAw@mail.gmail.com Backpatch-through: 13 Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/308773617d2dc8c717a695498c052722c5558660 Modified Files -------------- src/backend/utils/adt/regexp.c | 97 +++++++++++++++++++++++++---------- src/test/regress/expected/strings.out | 9 ++++ src/test/regress/sql/strings.sql | 3 ++ 3 files changed, 82 insertions(+), 27 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Amend recent fix for SIMILAR TO regex conversion. @ 2025-09-13 20:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-13 20:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Amend recent fix for SIMILAR TO regex conversion. Commit e3ffc3e91 fixed the translation of character classes in SIMILAR TO regular expressions. Unfortunately the fix broke a corner case: if there is an escape character right after the opening bracket (for example in "[\q]"), a closing bracket right after the escape sequence would not be seen as closing the character class. There were two more oversights: a backslash or a nested opening bracket right at the beginning of a character class should remove the special meaning from any following caret or closing bracket. This bug suggests that this code needs to be more readable, so also rename the variables "charclass_depth" and "charclass_start" to something more meaningful, rewrite an "if" cascade to be more consistent, and improve the commentary. Reported-by: Dominique Devienne <ddevienne@gmail.com> Reported-by: Stephan Springl <springl-psql@bfw-online.de> Author: Laurenz Albe <laurenz.albe@cybertec.at> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAFCRh-8NwJd0jq6P=R3qhHyqU7hw0BTor3W0SvUcii24et+zAw@mail.gmail.com Backpatch-through: 13 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/281ad4ed11d235cccad78fcbf7d807c615e1c0e8 Modified Files -------------- src/backend/utils/adt/regexp.c | 97 +++++++++++++++++++++++++---------- src/test/regress/expected/strings.out | 9 ++++ src/test/regress/sql/strings.sql | 3 ++ 3 files changed, 82 insertions(+), 27 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2025-09-13 20:56 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-09-13 20:56 pgsql: Amend recent fix for SIMILAR TO regex conversion. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-13 20:56 pgsql: Amend recent fix for SIMILAR TO regex conversion. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-13 20:56 pgsql: Amend recent fix for SIMILAR TO regex conversion. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-13 20:56 pgsql: Amend recent fix for SIMILAR TO regex conversion. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-13 20:56 pgsql: Amend recent fix for SIMILAR TO regex conversion. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-13 20:56 pgsql: Amend recent fix for SIMILAR TO regex conversion. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-13 20:56 pgsql: Amend recent fix for SIMILAR TO regex conversion. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox