Skip to content

Commit

Permalink
Backporting 273d8eb Proper fix for disabling warnings in read_statist…
Browse files Browse the repository at this point in the history
…ics_for_table()
  • Loading branch information
Varun Gupta committed Sep 23, 2019
1 parent 2931fd2 commit ab9f378
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 186 deletions.
1 change: 1 addition & 0 deletions mysql-test/include/ctype_utf8_ilseq.inc
Expand Up @@ -14,6 +14,7 @@ SHOW CREATE TABLE t1;

INSERT INTO t1 (ch) VALUES ('admin'),('admin1');
SELECT ch FROM t1 WHERE ch='admin𝌆';
EXPLAIN SELECT ch FROM t1 WHERE ch='admin𝌆';
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin𝌆';
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin𝌆';
DELETE FROM t1;
Expand Down
20 changes: 20 additions & 0 deletions mysql-test/r/compare.result
Expand Up @@ -100,3 +100,23 @@ CREATE TABLE t1(a INT ZEROFILL);
SELECT 1 FROM t1 WHERE t1.a IN (1, t1.a) AND t1.a=2;
1
DROP TABLE t1;
CREATE TABLE t1 (a char(2), index (a));
insert into t1 values ("aa"),("bb");
select * from t1 where a="aa";
a
aa
select * from t1 where a="aaa";
a
select * from t1 where a="aa ";
a
aa
select * from t1 where a>="aaa";
a
bb
explain select * from t1 where a="aaa";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 3 const 1 Using where; Using index
explain select * from t1 where a="aa ";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 3 const 1 Using where; Using index
drop table t1;
46 changes: 6 additions & 40 deletions mysql-test/r/ctype_uca.result
Expand Up @@ -6748,14 +6748,13 @@ t1 CREATE TABLE `t1` (
INSERT INTO t1 (ch) VALUES ('admin'),('admin1');
SELECT ch FROM t1 WHERE ch='admin𝌆';
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN SELECT ch FROM t1 WHERE ch='admin𝌆';
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
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin𝌆';
ch
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin𝌆';
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
DELETE FROM t1;
INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????');
INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b');
Expand All @@ -6771,22 +6770,14 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch;
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch;
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch;
ch
a
Expand Down Expand Up @@ -6829,8 +6820,6 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch;
ch
a
Expand All @@ -6850,14 +6839,10 @@ ab
az
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch;
ch
a
Expand All @@ -6877,8 +6862,6 @@ ab
az
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch;
ch
z
Expand All @@ -6889,24 +6872,16 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch;
ch
z
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch;
ch
z
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
ALTER TABLE t1 DROP KEY ch;
# 0xD18F would be a good 2-byte character, 0xD1 is an incomplete sequence
SET @query=CONCAT('SELECT ch FROM t1 WHERE ch=''a', 0xD1,'''');
Expand Down Expand Up @@ -6992,14 +6967,13 @@ t1 CREATE TABLE `t1` (
INSERT INTO t1 (ch) VALUES ('admin'),('admin1');
SELECT ch FROM t1 WHERE ch='admin𝌆';
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN SELECT ch FROM t1 WHERE ch='admin𝌆';
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
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin𝌆';
ch
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin𝌆';
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
DELETE FROM t1;
INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????');
INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b');
Expand All @@ -7015,22 +6989,14 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch;
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch;
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch;
ch
a
Expand Down
31 changes: 3 additions & 28 deletions mysql-test/r/ctype_uca_innodb.result
Expand Up @@ -23,14 +23,13 @@ t1 CREATE TABLE `t1` (
INSERT INTO t1 (ch) VALUES ('admin'),('admin1');
SELECT ch FROM t1 WHERE ch='admin𝌆';
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN SELECT ch FROM t1 WHERE ch='admin𝌆';
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
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin𝌆';
ch
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin𝌆';
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
DELETE FROM t1;
INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????');
INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b');
Expand All @@ -46,22 +45,14 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch;
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch;
ch
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch;
ch
a
Expand Down Expand Up @@ -104,8 +95,6 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch;
ch
a
Expand All @@ -125,14 +114,10 @@ ab
az
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch;
ch
a
Expand All @@ -152,8 +137,6 @@ ab
az
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch;
ch
z
Expand All @@ -164,24 +147,16 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch;
ch
z
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch;
ch
z
Warnings:
Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
ALTER TABLE t1 DROP KEY ch;
# 0xD18F would be a good 2-byte character, 0xD1 is an incomplete sequence
SET @query=CONCAT('SELECT ch FROM t1 WHERE ch=''a', 0xD1,'''');
Expand Down

0 comments on commit ab9f378

Please sign in to comment.