Skip to content

Commit

Permalink
MDEV-8613 Full table scan for WHERE indexed_varchar_column <=> 'bad-c…
Browse files Browse the repository at this point in the history
…haracter'
  • Loading branch information
Alexander Barkov committed Aug 13, 2015
1 parent 60985e5 commit 0750b2d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
12 changes: 12 additions & 0 deletions mysql-test/r/range.result
Original file line number Diff line number Diff line change
Expand Up @@ -2263,5 +2263,17 @@ a b
70 NULL
DROP TABLE t1;
#
# MDEV-8613 Full table scan for WHERE indexed_varchar_column <=> 'bad-character'
#
SET NAMES utf8;
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8, KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e');
EXPLAIN SELECT * FROM t1 WHERE a<=>'😎';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9F\x98\x8E' for column 'a' at row 1
DROP TABLE t1;
#
# End of 10.1 tests
#
9 changes: 9 additions & 0 deletions mysql-test/t/range.test
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,15 @@ SELECT * FROM t1 WHERE 10<>a;
DROP TABLE t1;


--echo #
--echo # MDEV-8613 Full table scan for WHERE indexed_varchar_column <=> 'bad-character'
--echo #
SET NAMES utf8;
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8, KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e');
EXPLAIN SELECT * FROM t1 WHERE a<=>'😎';
DROP TABLE t1;

--echo #
--echo # End of 10.1 tests
--echo #
2 changes: 1 addition & 1 deletion sql/opt_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7845,7 +7845,7 @@ Item_bool_func::get_mm_leaf(RANGE_OPT_PARAM *param,
err= value->save_in_field_no_warnings(field, 1);
if (err == 2 && field->cmp_type() == STRING_RESULT)
{
if (type == EQ_FUNC)
if (type == EQ_FUNC || type == EQUAL_FUNC)
{
tree= new (alloc) SEL_ARG(field, 0, 0);
tree->type= SEL_ARG::IMPOSSIBLE;
Expand Down

0 comments on commit 0750b2d

Please sign in to comment.