Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 10.0, 5.5
-
Fix Version/s: 5.5.43
-
Component/s: Character Sets
-
Labels:None
Description
The test case shows that SELECT returns a row that doesn't match the WHERE condition. This only happens when the column is not indexed, if there's an index the result is correct (no rows found).
DROP DATABASE IF EXISTS `strict_unicode_test`;
SET NAMES 'utf8' COLLATE 'utf8_unicode_ci';
SET SESSION sql_mode='STRICT_ALL_TABLES';
CREATE DATABASE `strict_unicode_test` COLLATE utf8_unicode_ci;
USE `strict_unicode_test`;
SHOW VARIABLES LIKE 'coll%';
SHOW VARIABLES LIKE 'character%';
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`login` varchar(60) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO users (login) VALUES ('admin');
SELECT * FROM `users` WHERE `login` = 'adminπ';
SHOW WARNINGS;
Gliffy Diagrams
Attachments
Issue Links
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
I think the following failure is related to the described problem (please extract it into a separate issue if it turns out to be different):
DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 (f1 CHAR(3)) ENGINE=MyISAM CHARSET utf8; INSERT INTO t1 VALUES ('foo'),('bar'); CREATE TABLE t2 (s char(3)) ENGINE=MyISAM CHARSET latin1; INSERT INTO t2 VALUES ('qux'),('qqq'); # The following result is correct: SELECT * FROM t1 WHERE (f1 < 'qux') IS NULL; # But this is not: SELECT * FROM t1 WHERE (f1 < (SELECT s FROM t2 LIMIT 1)) IS NULL; # And even this works, though it shouldn't: SELECT * FROM t1 WHERE (f1 < (SELECT s FROM t2)) IS NULL; DROP TABLE t1, t2;I think it's related, because if t2 is also UTF8, there is no problem:
DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 (f1 CHAR(3)) ENGINE=MyISAM CHARSET utf8; INSERT INTO t1 VALUES ('foo'),('bar'); CREATE TABLE t2 (s char(3)) ENGINE=MyISAM CHARSET utf8; INSERT INTO t2 VALUES ('qux'),('qqq'); # The following result is correct: SELECT * FROM t1 WHERE (f1 < 'qux') IS NULL; # Not this is okay too: SELECT * FROM t1 WHERE (f1 < (SELECT s FROM t2 LIMIT 1)) IS NULL; # And this one produces the expected error message: SELECT * FROM t1 WHERE (f1 < (SELECT s FROM t2)) IS NULL; DROP TABLE t1, t2;