Skip to content

Commit 0750b2d

Browse files
author
Alexander Barkov
committed
MDEV-8613 Full table scan for WHERE indexed_varchar_column <=> 'bad-character'
1 parent 60985e5 commit 0750b2d

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

mysql-test/r/range.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,5 +2263,17 @@ a b
22632263
70 NULL
22642264
DROP TABLE t1;
22652265
#
2266+
# MDEV-8613 Full table scan for WHERE indexed_varchar_column <=> 'bad-character'
2267+
#
2268+
SET NAMES utf8;
2269+
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8, KEY(a)) ENGINE=MyISAM;
2270+
INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e');
2271+
EXPLAIN SELECT * FROM t1 WHERE a<=>'😎';
2272+
id select_type table type possible_keys key key_len ref rows Extra
2273+
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2274+
Warnings:
2275+
Warning 1366 Incorrect string value: '\xF0\x9F\x98\x8E' for column 'a' at row 1
2276+
DROP TABLE t1;
2277+
#
22662278
# End of 10.1 tests
22672279
#

mysql-test/t/range.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,15 @@ SELECT * FROM t1 WHERE 10<>a;
17951795
DROP TABLE t1;
17961796

17971797

1798+
--echo #
1799+
--echo # MDEV-8613 Full table scan for WHERE indexed_varchar_column <=> 'bad-character'
1800+
--echo #
1801+
SET NAMES utf8;
1802+
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8, KEY(a)) ENGINE=MyISAM;
1803+
INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e');
1804+
EXPLAIN SELECT * FROM t1 WHERE a<=>'😎';
1805+
DROP TABLE t1;
1806+
17981807
--echo #
17991808
--echo # End of 10.1 tests
18001809
--echo #

sql/opt_range.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7845,7 +7845,7 @@ Item_bool_func::get_mm_leaf(RANGE_OPT_PARAM *param,
78457845
err= value->save_in_field_no_warnings(field, 1);
78467846
if (err == 2 && field->cmp_type() == STRING_RESULT)
78477847
{
7848-
if (type == EQ_FUNC)
7848+
if (type == EQ_FUNC || type == EQUAL_FUNC)
78497849
{
78507850
tree= new (alloc) SEL_ARG(field, 0, 0);
78517851
tree->type= SEL_ARG::IMPOSSIBLE;

0 commit comments

Comments
 (0)