mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Fix planner's test for case-foldable characters in ILIKE with ICU.
As coded, the ICU-collation path in pattern_char_isalpha() failed
to consider regular ASCII letters to be case-varying. This led to
like_fixed_prefix treating too much of an ILIKE pattern as being a
fixed prefix, so that indexscans derived from an ILIKE clause might
miss entries that they should find.
Per bug #15892 from James Inform. This is an oversight in the original
ICU patch (commit eccfef81e
), so back-patch to v10 where that came in.
Discussion: https://postgr.es/m/15892-e5d2bea3e8a04a1b@postgresql.org
This commit is contained in:
@ -976,6 +976,38 @@ SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_t
|
||||
collate_test1_idx4 | CREATE INDEX collate_test1_idx4 ON collate_tests.collate_test1 USING btree (((b || 'foo'::text)) COLLATE "POSIX")
|
||||
(4 rows)
|
||||
|
||||
set enable_seqscan = off;
|
||||
explain (costs off)
|
||||
select * from collate_test1 where b ilike 'abc';
|
||||
QUERY PLAN
|
||||
-------------------------------
|
||||
Seq Scan on collate_test1
|
||||
Filter: (b ~~* 'abc'::text)
|
||||
(2 rows)
|
||||
|
||||
select * from collate_test1 where b ilike 'abc';
|
||||
a | b
|
||||
---+-----
|
||||
1 | abc
|
||||
4 | ABC
|
||||
(2 rows)
|
||||
|
||||
explain (costs off)
|
||||
select * from collate_test1 where b ilike 'ABC';
|
||||
QUERY PLAN
|
||||
-------------------------------
|
||||
Seq Scan on collate_test1
|
||||
Filter: (b ~~* 'ABC'::text)
|
||||
(2 rows)
|
||||
|
||||
select * from collate_test1 where b ilike 'ABC';
|
||||
a | b
|
||||
---+-----
|
||||
1 | abc
|
||||
4 | ABC
|
||||
(2 rows)
|
||||
|
||||
reset enable_seqscan;
|
||||
-- schema manipulation commands
|
||||
CREATE ROLE regress_test_role;
|
||||
CREATE SCHEMA test_schema;
|
||||
@ -1860,8 +1892,9 @@ SELECT (SELECT count(*) FROM test33_0) <> (SELECT count(*) FROM test33_1);
|
||||
(1 row)
|
||||
|
||||
-- cleanup
|
||||
RESET search_path;
|
||||
SET client_min_messages TO warning;
|
||||
DROP SCHEMA collate_tests CASCADE;
|
||||
RESET search_path;
|
||||
RESET client_min_messages;
|
||||
-- leave a collation for pg_upgrade test
|
||||
CREATE COLLATION coll_icu_upgrade FROM "und-x-icu";
|
||||
|
@ -333,6 +333,15 @@ CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C")); -- fail
|
||||
|
||||
SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1;
|
||||
|
||||
set enable_seqscan = off;
|
||||
explain (costs off)
|
||||
select * from collate_test1 where b ilike 'abc';
|
||||
select * from collate_test1 where b ilike 'abc';
|
||||
explain (costs off)
|
||||
select * from collate_test1 where b ilike 'ABC';
|
||||
select * from collate_test1 where b ilike 'ABC';
|
||||
reset enable_seqscan;
|
||||
|
||||
|
||||
-- schema manipulation commands
|
||||
|
||||
@ -704,9 +713,10 @@ SELECT (SELECT count(*) FROM test33_0) <> (SELECT count(*) FROM test33_1);
|
||||
|
||||
|
||||
-- cleanup
|
||||
RESET search_path;
|
||||
SET client_min_messages TO warning;
|
||||
DROP SCHEMA collate_tests CASCADE;
|
||||
RESET search_path;
|
||||
RESET client_min_messages;
|
||||
|
||||
-- leave a collation for pg_upgrade test
|
||||
CREATE COLLATION coll_icu_upgrade FROM "und-x-icu";
|
||||
|
Reference in New Issue
Block a user