diff options
-rw-r--r-- | src/backend/utils/adt/like_support.c | 4 | ||||
-rw-r--r-- | src/test/regress/expected/strings.out | 16 | ||||
-rw-r--r-- | src/test/regress/sql/strings.sql | 13 |
3 files changed, 32 insertions, 1 deletions
diff --git a/src/backend/utils/adt/like_support.c b/src/backend/utils/adt/like_support.c index a65e63736c4..7528c80f7c3 100644 --- a/src/backend/utils/adt/like_support.c +++ b/src/backend/utils/adt/like_support.c @@ -267,8 +267,10 @@ match_pattern_prefix(Node *leftop, * precise error messages.) (It should be possible to support at least * Pattern_Prefix_Exact, but no point as along as the actual * pattern-matching implementations don't support it.) + * + * expr_coll is not set for a non-collation-aware data type such as bytea. */ - if (!get_collation_isdeterministic(expr_coll)) + if (expr_coll && !get_collation_isdeterministic(expr_coll)) return NIL; /* diff --git a/src/test/regress/expected/strings.out b/src/test/regress/expected/strings.out index 2f5f58273ab..7c7f8726fcc 100644 --- a/src/test/regress/expected/strings.out +++ b/src/test/regress/expected/strings.out @@ -1102,6 +1102,22 @@ SELECT 'jack' LIKE '%____%' AS t; (1 row) -- +-- basic tests of LIKE with indexes +-- +CREATE TABLE texttest (a text PRIMARY KEY, b int); +SELECT * FROM texttest WHERE a LIKE '%1%'; + a | b +---+--- +(0 rows) + +CREATE TABLE byteatest (a bytea PRIMARY KEY, b int); +SELECT * FROM byteatest WHERE a LIKE '%1%'; + a | b +---+--- +(0 rows) + +DROP TABLE texttest, byteatest; +-- -- test implicit type conversion -- -- E021-07 character concatenation diff --git a/src/test/regress/sql/strings.sql b/src/test/regress/sql/strings.sql index 1f4cd88a18f..9cd2bc5d7e8 100644 --- a/src/test/regress/sql/strings.sql +++ b/src/test/regress/sql/strings.sql @@ -324,6 +324,19 @@ SELECT 'jack' LIKE '%____%' AS t; -- +-- basic tests of LIKE with indexes +-- + +CREATE TABLE texttest (a text PRIMARY KEY, b int); +SELECT * FROM texttest WHERE a LIKE '%1%'; + +CREATE TABLE byteatest (a bytea PRIMARY KEY, b int); +SELECT * FROM byteatest WHERE a LIKE '%1%'; + +DROP TABLE texttest, byteatest; + + +-- -- test implicit type conversion -- |