]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Adjust regex for test with opening parenthesis in character classes
authorMichael Paquier <michael@paquier.xyz>
Wed, 28 May 2025 00:43:46 +0000 (09:43 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 28 May 2025 00:43:46 +0000 (09:43 +0900)
As written, the test was throwing an error because of an unbalanced
parenthesis.  The regex used in the test is adjusted to not fail and to
test the case of an opening parenthesis in a character class after some
nested square brackets.

Oversight in d46911e584d4.

Discussion: https://postgr.es/m/16ab039d1af455652bdf4173402ddda145f2c73b.camel@cybertec.at

src/test/regress/expected/strings.out
src/test/regress/sql/strings.sql

index ff6b00e5672a8a4316c709459f9c036252da11c3..cb7aa5a1f2c6056f250fdcc558eea61bb87400a1 100644 (file)
@@ -631,8 +631,13 @@ EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '$[$[:alnum:]$]$'
 (2 rows)
 
 -- Opening parenthesis "("
-EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '([([:alnum:](](';
-ERROR:  invalid regular expression: parentheses () not balanced
+EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '()[([:alnum:](]()';
+                      QUERY PLAN                      
+------------------------------------------------------
+ Seq Scan on text_tbl
+   Filter: (f1 ~ '^(?:(?:)[([:alnum:](](?:))$'::text)
+(2 rows)
+
 -- Caret "^"
 EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '^[^[:alnum:]^[^^][[^^]][\^][[\^]]\^]^';
                                QUERY PLAN                               
index e1c520580fbb0def5ea68d799224bc8b260f1cd8..1f01919496a8fa204080d4dfa96df0664e16eb4a 100644 (file)
@@ -204,7 +204,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '.[.[:alnum:].].'
 -- Dollar "$"
 EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '$[$[:alnum:]$]$';
 -- Opening parenthesis "("
-EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '([([:alnum:](](';
+EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '()[([:alnum:](]()';
 -- Caret "^"
 EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '^[^[:alnum:]^[^^][[^^]][\^][[\^]]\^]^';
 -- Closing square bracket "]" at the beginning of character class