[MDEV-8625] Bad result set with ignorable characters when using a prefix key Created: 2015-08-14  Updated: 2022-12-16

Status: Confirmed
Project: MariaDB Server
Component/s: Character Sets, Optimizer
Affects Version/s: 5.5, 10.0, 10.1, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
Fix Version/s: 10.1, 10.3

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: upstream


 Description   

This bug is known for a long time since adding UCA collations.

This script with no index:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci);
INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e'),('f'),('g'),('h');
SELECT * FROM t1 WHERE a<'\0b';

and this script with KEY(a):

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci, KEY(a));
INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e'),('f'),('g'),('h');
SELECT * FROM t1 WHERE a<'\0b';

correctly return one row:

+------+
| a    |
+------+
| a    |
+------+
1 row in set (0.00 sec)

This script with a prefix index KEY(a(1))

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci, KEY(a(1)));
INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e'),('f'),('g'),('h');
SELECT * FROM t1 WHERE a<'\0b';

erroneously returns empty set.


Generated at Thu Feb 08 07:28:33 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.