diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/regex.out | 63 | ||||
-rw-r--r-- | src/test/regress/sql/regex.sql | 10 |
2 files changed, 73 insertions, 0 deletions
diff --git a/src/test/regress/expected/regex.out b/src/test/regress/expected/regex.out index dc0c713b408..658538fd419 100644 --- a/src/test/regress/expected/regex.out +++ b/src/test/regress/expected/regex.out @@ -90,3 +90,66 @@ select substring('a' from '((a)+)'); a (1 row) +-- Test conversion of regex patterns to indexable conditions +explain (costs off) select * from pg_proc where proname ~ 'abc'; + QUERY PLAN +----------------------------------- + Seq Scan on pg_proc + Filter: (proname ~ 'abc'::text) +(2 rows) + +explain (costs off) select * from pg_proc where proname ~ '^abc'; + QUERY PLAN +---------------------------------------------------------------------- + Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Index Cond: ((proname >= 'abc'::name) AND (proname < 'abd'::name)) + Filter: (proname ~ '^abc'::text) +(3 rows) + +explain (costs off) select * from pg_proc where proname ~ '^abc$'; + QUERY PLAN +------------------------------------------------------------ + Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Index Cond: (proname = 'abc'::name) + Filter: (proname ~ '^abc$'::text) +(3 rows) + +explain (costs off) select * from pg_proc where proname ~ '^abcd*e'; + QUERY PLAN +---------------------------------------------------------------------- + Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Index Cond: ((proname >= 'abc'::name) AND (proname < 'abd'::name)) + Filter: (proname ~ '^abcd*e'::text) +(3 rows) + +explain (costs off) select * from pg_proc where proname ~ '^abc+d'; + QUERY PLAN +---------------------------------------------------------------------- + Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Index Cond: ((proname >= 'abc'::name) AND (proname < 'abd'::name)) + Filter: (proname ~ '^abc+d'::text) +(3 rows) + +explain (costs off) select * from pg_proc where proname ~ '^(abc)(def)'; + QUERY PLAN +---------------------------------------------------------------------------- + Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Index Cond: ((proname >= 'abcdef'::name) AND (proname < 'abcdeg'::name)) + Filter: (proname ~ '^(abc)(def)'::text) +(3 rows) + +explain (costs off) select * from pg_proc where proname ~ '^(abc)$'; + QUERY PLAN +------------------------------------------------------------ + Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Index Cond: (proname = 'abc'::name) + Filter: (proname ~ '^(abc)$'::text) +(3 rows) + +explain (costs off) select * from pg_proc where proname ~ '^(abc)?d'; + QUERY PLAN +---------------------------------------- + Seq Scan on pg_proc + Filter: (proname ~ '^(abc)?d'::text) +(2 rows) + diff --git a/src/test/regress/sql/regex.sql b/src/test/regress/sql/regex.sql index 9fdcb2f5bd5..c29ed05d768 100644 --- a/src/test/regress/sql/regex.sql +++ b/src/test/regress/sql/regex.sql @@ -24,3 +24,13 @@ select 'abc abc abd' ~ '^(.+)( \1)+$' as f; select substring('asd TO foo' from ' TO (([a-z0-9._]+|"([^"]+|"")+")+)'); select substring('a' from '((a))+'); select substring('a' from '((a)+)'); + +-- Test conversion of regex patterns to indexable conditions +explain (costs off) select * from pg_proc where proname ~ 'abc'; +explain (costs off) select * from pg_proc where proname ~ '^abc'; +explain (costs off) select * from pg_proc where proname ~ '^abc$'; +explain (costs off) select * from pg_proc where proname ~ '^abcd*e'; +explain (costs off) select * from pg_proc where proname ~ '^abc+d'; +explain (costs off) select * from pg_proc where proname ~ '^(abc)(def)'; +explain (costs off) select * from pg_proc where proname ~ '^(abc)$'; +explain (costs off) select * from pg_proc where proname ~ '^(abc)?d'; |