mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Unbreak index optimization for LIKE on bytea
The same code is used to handle both text and bytea, but bytea is not collation-aware, so we shouldn't call get_collation_isdeterministic() in that case, since that will error out with an invalid collation. Reported-by: Jeevan Chalke <jeevan.chalke@enterprisedb.com> Discussion: https://www.postgresql.org/message-id/flat/CAM2%2B6%3DWaf3qJ1%3DyVTUH8_yG-SC0xcBMY%2BSFLhvKKNnWNXSUDBw%40mail.gmail.com
This commit is contained in:
@ -1101,6 +1101,22 @@ SELECT 'jack' LIKE '%____%' AS t;
|
||||
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
|
||||
--
|
||||
|
@ -323,6 +323,19 @@ SELECT 'foo' LIKE '%__' as t, 'foo' LIKE '%___' as t, 'foo' LIKE '%____' as f;
|
||||
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
|
||||
--
|
||||
|
Reference in New Issue
Block a user