Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.0(EOL), 10.1(EOL)
Description
In this script:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a VARBINARY(10));
|
INSERT INTO t1 VALUES ('a');
|
SELECT * FROM t1 WHERE COLLATION(a)='binary';
|
SELECT * FROM t1 WHERE a='a';
|
the two SELECT queries return one row.
Now if I join both conditions using AND in the same query:
SELECT * FROM t1 WHERE COLLATION(a)='binary' AND a='a';
|
It returns empty set.
A similar script:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a VARBINARY(10));
|
INSERT INTO t1 VALUES ('a');
|
SELECT * FROM t1 WHERE CHARSET(a)='binary';
|
SELECT * FROM t1 WHERE a='a';
|
SELECT * FROM t1 WHERE CHARSET(a)='binary' AND a='a';
|
A similar script:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a VARBINARY(10));
|
INSERT INTO t1 VALUES ('a');
|
SELECT * FROM t1 WHERE COERCIBILITY(a)=2;
|
SELECT * FROM t1 WHERE a='a';
|
SELECT * FROM t1 WHERE COERCIBILITY(a)=2 AND a='a';
|
A similar script:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a VARBINARY(10));
|
INSERT INTO t1 VALUES ('a');
|
SELECT * FROM t1 WHERE WEIGHT_STRING(a)='a';
|
SELECT * FROM t1 WHERE a='a';
|
SELECT * FROM t1 WHERE WEIGHT_STRING(a)='a' AND a='a';
|
After the fix
EXPLAIN EXTENDED SELECT * FROM t1 WHERE COLLATION(a)='binary' AND a='a';
SHOW WARNINGS;
returns
+-------+------+------------------------------------------------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------------------------------------------------+
| Note | 1003 | select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 'a') |
+-------+------+------------------------------------------------------------------------------+
MySQL-5.7.8 does not support propagation in the same query:
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------+
| Note | 1003 | /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') and (collation(`test`.`t1`.`a`) = 'binary')) |
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------+