Description:
When performing a LIKE comparison using the utf8_unicode_ci collation and using an index
a trailing % doesn't equal zero characters. % at the beginning and middle of a search
string does allow itself to equal no character.
So
SELECT c FROM t WHERE c LIKE 'a%';
will not select "a" but it will select "aa".
This works fine in utf8_general_ci and ucs2_unicode_ci. I tested with the latest bk
pulls.
How to repeat:
#trailing wild card with index bug in LIKE comparisons
DROP TABLE IF EXISTS t;
CREATE TABLE t (
c char(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO t VALUES ('a'),('ab'),('aba');
SELECT c FROM t WHERE c LIKE 'a%';
#selects 3 rows without an index
ALTER TABLE t ADD INDEX (c);
SELECT c FROM t WHERE c LIKE 'a%';
#should find 3 rows but only finds 2
DROP TABLE t;
Description: When performing a LIKE comparison using the utf8_unicode_ci collation and using an index a trailing % doesn't equal zero characters. % at the beginning and middle of a search string does allow itself to equal no character. So SELECT c FROM t WHERE c LIKE 'a%'; will not select "a" but it will select "aa". This works fine in utf8_general_ci and ucs2_unicode_ci. I tested with the latest bk pulls. How to repeat: #trailing wild card with index bug in LIKE comparisons DROP TABLE IF EXISTS t; CREATE TABLE t ( c char(20) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; INSERT INTO t VALUES ('a'),('ab'),('aba'); SELECT c FROM t WHERE c LIKE 'a%'; #selects 3 rows without an index ALTER TABLE t ADD INDEX (c); SELECT c FROM t WHERE c LIKE 'a%'; #should find 3 rows but only finds 2 DROP TABLE t;