Skip to content

Commit 0c09922

Browse files
committed
Adjust regex for test with opening parenthesis in character classes
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 d46911e. Discussion: https://postgr.es/m/16ab039d1af455652bdf4173402ddda145f2c73b.camel@cybertec.at
1 parent 1fe15d2 commit 0c09922

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/test/regress/expected/strings.out

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,13 @@ EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '$[$[:alnum:]$]$'
599599
(2 rows)
600600

601601
-- Opening parenthesis "("
602-
EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '([([:alnum:](](';
603-
ERROR: invalid regular expression: parentheses () not balanced
602+
EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '()[([:alnum:](]()';
603+
QUERY PLAN
604+
------------------------------------------------------
605+
Seq Scan on text_tbl
606+
Filter: (f1 ~ '^(?:(?:)[([:alnum:](](?:))$'::text)
607+
(2 rows)
608+
604609
-- Caret "^"
605610
EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '^[^[:alnum:]^[^^][[^^]][\^][[\^]]\^]^';
606611
QUERY PLAN

src/test/regress/sql/strings.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '.[.[:alnum:].].'
196196
-- Dollar "$"
197197
EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '$[$[:alnum:]$]$';
198198
-- Opening parenthesis "("
199-
EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '([([:alnum:](](';
199+
EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '()[([:alnum:](]()';
200200
-- Caret "^"
201201
EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '^[^[:alnum:]^[^^][[^^]][\^][[\^]]\^]^';
202202
-- Closing square bracket "]" at the beginning of character class

0 commit comments

Comments
 (0)