diff options
| author | Andrew Gierth | 2018-09-12 18:31:06 +0000 |
|---|---|---|
| committer | Andrew Gierth | 2018-09-12 18:31:06 +0000 |
| commit | b7f6bcbffcc0b41d783c0c9c61766428159969ff (patch) | |
| tree | 97f6adb12342296dd1d7dba55586141914da4bb1 /src/test | |
| parent | ba37349cff781120f61b2778257f594f0d10253c (diff) | |
Repair bug in regexp split performance improvements.
Commit c8ea87e4b introduced a temporary conversion buffer for
substrings extracted during regexp splits. Unfortunately the code that
sized it was failing to ignore the effects of ignored degenerate
regexp matches, so for regexp_split_* calls it could under-size the
buffer in such cases.
Fix, and add some regression test cases (though those will only catch
the bug if run in a multibyte encoding).
Backpatch to 9.3 as the faulty code was.
Thanks to the PostGIS project, Regina Obe and Paul Ramsey for the
report (via IRC) and assistance in analysis. Patch by me.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/strings.out | 18 | ||||
| -rw-r--r-- | src/test/regress/sql/strings.sql | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/test/regress/expected/strings.out b/src/test/regress/expected/strings.out index cbe66c375ca..189bdffdca0 100644 --- a/src/test/regress/expected/strings.out +++ b/src/test/regress/expected/strings.out @@ -674,6 +674,24 @@ SELECT regexp_split_to_array('123456','.'); {"","","","","","",""} (1 row) +SELECT regexp_split_to_array('123456',''); + regexp_split_to_array +----------------------- + {1,2,3,4,5,6} +(1 row) + +SELECT regexp_split_to_array('123456','(?:)'); + regexp_split_to_array +----------------------- + {1,2,3,4,5,6} +(1 row) + +SELECT regexp_split_to_array('1',''); + regexp_split_to_array +----------------------- + {1} +(1 row) + -- errors SELECT foo, length(foo) FROM regexp_split_to_table('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'zippy') AS foo; ERROR: invalid regexp option: "z" diff --git a/src/test/regress/sql/strings.sql b/src/test/regress/sql/strings.sql index 5a82237870e..f2203ef1b1d 100644 --- a/src/test/regress/sql/strings.sql +++ b/src/test/regress/sql/strings.sql @@ -188,6 +188,9 @@ SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', 'nom SELECT regexp_split_to_array('123456','1'); SELECT regexp_split_to_array('123456','6'); SELECT regexp_split_to_array('123456','.'); +SELECT regexp_split_to_array('123456',''); +SELECT regexp_split_to_array('123456','(?:)'); +SELECT regexp_split_to_array('1',''); -- errors SELECT foo, length(foo) FROM regexp_split_to_table('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'zippy') AS foo; SELECT regexp_split_to_array('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'iz'); |
