Bug #121751 Query with `~ CAST(FALSE AS BINARY)` and IN subquery fails with ERROR 3854 when index access is disabled
Description:
The same query returns 1 row normally with the `/*+ INDEX(t1 c1) */` hint, but fails with `ERROR 3854 (HY000): Cannot convert string '\xCF' from binary to utf8mb4` when the index is disabled with `/*+ NO_INDEX(t1)*/`.
How to repeat:
mysql> CREATE TABLE t1 (c1 TINYTEXT, UNIQUE (c1(1)));
Query OK, 0 rows affected (0.334 sec)
mysql> INSERT INTO t1 (c1) VALUES ('m8NdIyAU01');
Query OK, 1 row affected (0.113 sec)
-- with NO_INDEX hint
mysql> SELECT * FROM t1 WHERE (NOT ((~ CAST(FALSE AS BINARY)) IN (SELECT /*+ NO_INDEX(t1)*/ c1 FROM t1))) ORDER BY c1;
ERROR 3854 (HY000): Cannot convert string '\xCF' from binary to utf8mb4
-- with INDEX hint
mysql> SELECT * FROM t1 WHERE (NOT ((~ CAST(FALSE AS BINARY)) IN (SELECT /*+ INDEX(t1 c1) */c1 FROM t1))) ORDER BY c1;
+------------+
| c1 |
+------------+
| m8NdIyAU01 |
+------------+
1 row in set, 1 warning (0.007 sec)
-- check warnings
mysql> show warnings;
+---------+------+---------------------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------------------+
| Warning | 1366 | Incorrect string value: '\xCF' for column 'c1' at row 1 |
+---------+------+---------------------------------------------------------+
1 row in set (0.004 sec)
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.048 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: The same query returns 1 row normally with the `/*+ INDEX(t1 c1) */` hint, but fails with `ERROR 3854 (HY000): Cannot convert string '\xCF' from binary to utf8mb4` when the index is disabled with `/*+ NO_INDEX(t1)*/`. How to repeat: mysql> CREATE TABLE t1 (c1 TINYTEXT, UNIQUE (c1(1))); Query OK, 0 rows affected (0.334 sec) mysql> INSERT INTO t1 (c1) VALUES ('m8NdIyAU01'); Query OK, 1 row affected (0.113 sec) -- with NO_INDEX hint mysql> SELECT * FROM t1 WHERE (NOT ((~ CAST(FALSE AS BINARY)) IN (SELECT /*+ NO_INDEX(t1)*/ c1 FROM t1))) ORDER BY c1; ERROR 3854 (HY000): Cannot convert string '\xCF' from binary to utf8mb4 -- with INDEX hint mysql> SELECT * FROM t1 WHERE (NOT ((~ CAST(FALSE AS BINARY)) IN (SELECT /*+ INDEX(t1 c1) */c1 FROM t1))) ORDER BY c1; +------------+ | c1 | +------------+ | m8NdIyAU01 | +------------+ 1 row in set, 1 warning (0.007 sec) -- check warnings mysql> show warnings; +---------+------+---------------------------------------------------------+ | Level | Code | Message | +---------+------+---------------------------------------------------------+ | Warning | 1366 | Incorrect string value: '\xCF' for column 'c1' at row 1 | +---------+------+---------------------------------------------------------+ 1 row in set (0.004 sec)