Adjust regex for test with opening parenthesis in character classes
authorMichael Paquier <[email protected]>
Wed, 28 May 2025 00:43:50 +0000 (09:43 +0900)
committerMichael Paquier <[email protected]>
Wed, 28 May 2025 00:43:50 +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[email protected]

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

index 8d4ba17628faa55efa9a6bb7930b58e82669561b..43e351799381236e00df5d9f35b4ecc7605f514e 100644 (file)
@@ -599,8 +599,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 190d6c110f6c56bf97b0f8b40bc60546fdbc5ed7..481166276573448197c08ef28eccf149f57e9e0d 100644 (file)
@@ -196,7 +196,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