Skip to content

Commit 961d33a

Browse files
author
Tor Didriksen
committed
Bug#25516986 ORDER_BY_XXX TESTS FAIL WHEN CHANGING DEFAULT CHARACTER SET
To repeat: ./mtr --mem --charset-for-testdb=utf8mb4 order_by_all order_by_icp_mrr order_by_none order_by_sortkey Fix: re-record with explicit charset for queries/tables with mismatch in explain output. Also fix: ds_mrr-big --big-test, use latin1 because utf8mb4 gave plan change. Also fix: derived, use utf8mb4 except in cases with execution plan changes.
1 parent 8297d88 commit 961d33a

10 files changed

+188
-179
lines changed

mysql-test/include/order_by.inc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ CREATE TABLE t1 (
220220
info text NOT NULL default '',
221221
ipnr varchar(30) NOT NULL default '',
222222
PRIMARY KEY (member_id)
223-
) ENGINE=MyISAM PACK_KEYS=1;
223+
) charset utf8mb4 ENGINE=MyISAM PACK_KEYS=1;
224224

225225
insert into t1 (member_id) values (1),(2),(3);
226226
select member_id, nickname, voornaam FROM t1
@@ -231,7 +231,7 @@ drop table t1;
231231
# Test optimization of ORDER BY DESC
232232
#
233233

234-
create table t1 (a int not null, b int, c varchar(10), key (a, b, c));
234+
create table t1 (a int not null, b int, c varchar(10), key (a, b, c)) charset utf8mb4;
235235
insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b');
236236

237237
explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
@@ -397,7 +397,7 @@ CREATE TABLE t1 (
397397
KEY FieldKey (FieldKey),
398398
KEY LongField (FieldKey,LongVal),
399399
KEY StringField (FieldKey,StringVal(32))
400-
);
400+
) charset utf8mb4;
401401
INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
402402
EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
403403
SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
@@ -506,7 +506,8 @@ drop table t1, t2;
506506
# Bug #5428: a problem with small max_sort_length value
507507
#
508508

509-
create table t1 (a char(25));
509+
# max_sort_length is in number of bytes, use latin1 to avoid strnxfrm.
510+
create table t1 (a char(25)) charset latin1;
510511
insert into t1 set a = repeat('x', 20);
511512
insert into t1 set a = concat(repeat('x', 19), 'z');
512513
insert into t1 set a = concat(repeat('x', 19), 'ab');
@@ -898,10 +899,12 @@ DROP TABLE t1;
898899
#
899900

900901
CREATE TABLE t2 (a varchar(32), b int(11), c float, d double,
901-
UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c));
902+
UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c)) charset utf8mb4;
902903

903-
CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b));
904-
CREATE TABLE t3 (a varchar(32), b char(3), UNIQUE KEY a (a,b));
904+
CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b))
905+
charset utf8mb4;
906+
CREATE TABLE t3 (a varchar(32), b char(3), UNIQUE KEY a (a,b))
907+
charset utf8mb4;
905908

906909
--disable_query_log
907910
INSERT INTO t1 (a, b) VALUES
@@ -1360,7 +1363,7 @@ DROP TABLE t1,t2,t3;
13601363
--echo # WL#1393 - Optimizing filesort with small limit
13611364
--echo #
13621365

1363-
CREATE TABLE t1(f0 int auto_increment primary key, f1 int, f2 varchar(200));
1366+
CREATE TABLE t1(f0 int auto_increment primary key, f1 int, f2 varchar(200)) charset latin1;
13641367
INSERT INTO t1(f1, f2) VALUES
13651368
(0,"0"),(1,"1"),(2,"2"),(3,"3"),(4,"4"),(5,"5"),
13661369
(6,"6"),(7,"7"),(8,"8"),(9,"9"),(10,"10"),

mysql-test/r/derived.result

Lines changed: 47 additions & 47 deletions
Large diffs are not rendered by default.

mysql-test/r/ds_mrr-big.result

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ pk INTEGER NOT NULL,
1515
i1 INTEGER NOT NULL,
1616
c1 VARCHAR(10) NOT NULL,
1717
PRIMARY KEY (pk)
18-
);
18+
) charset latin1;
1919
INSERT INTO t1
2020
SELECT a, 1, 'MySQL' FROM thousand;
2121
CREATE TABLE t2 (
2222
pk INTEGER NOT NULL,
2323
c1 VARCHAR(10) NOT NULL,
2424
c2 varchar(10) NOT NULL,
2525
PRIMARY KEY (pk)
26-
);
26+
) charset latin1;
2727
INSERT INTO t2
2828
SELECT a, 'MySQL', 'MySQL' FROM ten;
2929
CREATE TABLE t3 (
3030
pk INTEGER NOT NULL,
3131
c1 VARCHAR(10) NOT NULL,
3232
PRIMARY KEY (pk)
33-
);
33+
) charset latin1;
3434
INSERT INTO t3
3535
SELECT a, 'MySQL' FROM hundred;
3636
CREATE TABLE t4 (
@@ -40,12 +40,12 @@ c2 varchar(10) NOT NULL,
4040
c3 varchar(10) NOT NULL,
4141
PRIMARY KEY (pk),
4242
KEY k1 (c1_key)
43-
);
43+
) charset latin1;
4444
CREATE TABLE t5 (
4545
pk INTEGER NOT NULL,
4646
c1 VARCHAR(10) NOT NULL,
4747
PRIMARY KEY (pk)
48-
);
48+
) charset latin1;
4949
INSERT INTO t5
5050
SELECT a, 'MySQL' FROM ten;
5151
set optimizer_switch=`mrr=on,mrr_cost_based=off`;

mysql-test/r/order_by_all.result

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ favo_muziek varchar(30) NOT NULL default '',
283283
info text NOT NULL default '',
284284
ipnr varchar(30) NOT NULL default '',
285285
PRIMARY KEY (member_id)
286-
) ENGINE=MyISAM PACK_KEYS=1;
286+
) charset utf8mb4 ENGINE=MyISAM PACK_KEYS=1;
287287
Warnings:
288288
Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'info' can't have a default value
289289
insert into t1 (member_id) values (1),(2),(3);
@@ -293,13 +293,13 @@ member_id nickname voornaam
293293
1
294294
2
295295
drop table t1;
296-
create table t1 (a int not null, b int, c varchar(10), key (a, b, c));
296+
create table t1 (a int not null, b int, c varchar(10), key (a, b, c)) charset utf8mb4;
297297
insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b');
298298
explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
299299
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
300-
1 SIMPLE t1 NULL range a a 22 NULL 2 100.00 Using where; Backward index scan; Using index
300+
1 SIMPLE t1 NULL range a a 52 NULL 2 100.00 Using where; Backward index scan; Using index
301301
Warnings:
302-
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`c` = 'b') and (`test`.`t1`.`a` = 1) and isnull(`test`.`t1`.`b`)) or (`test`.`t1`.`a` > 2)) order by `test`.`t1`.`a` desc
302+
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`a` = 1) and isnull(`test`.`t1`.`b`) and (`test`.`t1`.`c` = 'b')) or (`test`.`t1`.`a` > 2)) order by `test`.`t1`.`a` desc
303303
select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
304304
a b c
305305
1 NULL b
@@ -314,7 +314,7 @@ EXPLAIN
314314
"query_block": {
315315
"select_id": 1,
316316
"cost_info": {
317-
"query_cost": "2.38"
317+
"query_cost": "2.51"
318318
},
319319
"ordering_operation": {
320320
"using_filesort": false,
@@ -335,10 +335,10 @@ EXPLAIN
335335
"backward_index_scan": true,
336336
"using_index": true,
337337
"cost_info": {
338-
"read_cost": "1.38",
338+
"read_cost": "1.51",
339339
"eval_cost": "1.00",
340-
"prefix_cost": "2.38",
341-
"data_read_per_join": "240"
340+
"prefix_cost": "2.51",
341+
"data_read_per_join": "560"
342342
},
343343
"used_columns": [
344344
"a",
@@ -439,7 +439,7 @@ Warning 1265 Data truncated for column 'b' at row 2
439439
Warning 1265 Data truncated for column 'c' at row 3
440440
explain select * from t1 order by a, b, c;
441441
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
442-
1 SIMPLE t1 NULL index NULL a 20 NULL 11 100.00 Using index
442+
1 SIMPLE t1 NULL index NULL a 50 NULL 11 100.00 Using index
443443
Warnings:
444444
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`
445445
select * from t1 order by a, b, c;
@@ -457,7 +457,7 @@ a b c
457457
2 3 c
458458
explain select * from t1 order by a desc, b desc, c desc;
459459
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
460-
1 SIMPLE t1 NULL index NULL a 20 NULL 11 100.00 Backward index scan; Using index
460+
1 SIMPLE t1 NULL index NULL a 50 NULL 11 100.00 Backward index scan; Using index
461461
Warnings:
462462
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc,`test`.`t1`.`c` desc
463463
select * from t1 order by a desc, b desc, c desc;
@@ -475,9 +475,9 @@ a b c
475475
1 0
476476
explain select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc;
477477
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
478-
1 SIMPLE t1 NULL range a a 20 NULL 3 100.00 Using where; Backward index scan; Using index
478+
1 SIMPLE t1 NULL range a a 50 NULL 3 100.00 Using where; Backward index scan; Using index
479479
Warnings:
480-
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`c` = 'b') and (`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) or (`test`.`t1`.`a` > 2)) order by `test`.`t1`.`a` desc
480+
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1) and (`test`.`t1`.`c` = 'b')) or (`test`.`t1`.`a` > 2)) order by `test`.`t1`.`a` desc
481481
select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc;
482482
a b c
483483
1 1 b
@@ -693,11 +693,11 @@ StringVal mediumtext,
693693
KEY FieldKey (FieldKey),
694694
KEY LongField (FieldKey,LongVal),
695695
KEY StringField (FieldKey,StringVal(32))
696-
);
696+
) charset utf8mb4;
697697
INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
698698
EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
699699
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
700-
1 SIMPLE t1 NULL ref FieldKey,LongField,StringField LongField 38 const 3 100.00 Using index condition
700+
1 SIMPLE t1 NULL ref FieldKey,LongField,StringField LongField 146 const 3 100.00 Using index condition
701701
Warnings:
702702
Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` where (`test`.`t1`.`FieldKey` = '1') order by `test`.`t1`.`LongVal`
703703
SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
@@ -707,7 +707,7 @@ FieldKey LongVal StringVal
707707
1 2 1
708708
EXPLAIN SELECT * FROM t1 ignore index (FieldKey, LongField) WHERE FieldKey > '2' ORDER BY LongVal;
709709
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
710-
1 SIMPLE t1 NULL range StringField StringField 38 NULL 4 100.00 Using where; Using filesort
710+
1 SIMPLE t1 NULL range StringField StringField 146 NULL 4 100.00 Using where; Using filesort
711711
Warnings:
712712
Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` IGNORE INDEX (`LongField`) IGNORE INDEX (`FieldKey`) where (`test`.`t1`.`FieldKey` > '2') order by `test`.`t1`.`LongVal`
713713
SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
@@ -717,7 +717,7 @@ FieldKey LongVal StringVal
717717
3 3 3
718718
EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
719719
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
720-
1 SIMPLE t1 NULL range FieldKey,LongField,StringField LongField 38 NULL 4 100.00 Using index condition
720+
1 SIMPLE t1 NULL range FieldKey,LongField,StringField LongField 146 NULL 4 100.00 Using index condition
721721
Warnings:
722722
Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` where (`test`.`t1`.`FieldKey` > '2') order by `test`.`t1`.`FieldKey`,`test`.`t1`.`LongVal`
723723
SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
@@ -853,7 +853,7 @@ col2 col col
853853
2 2 2
854854
1 3 3
855855
drop table t1, t2;
856-
create table t1 (a char(25));
856+
create table t1 (a char(25)) charset latin1;
857857
insert into t1 set a = repeat('x', 20);
858858
insert into t1 set a = concat(repeat('x', 19), 'z');
859859
insert into t1 set a = concat(repeat('x', 19), 'ab');
@@ -1883,19 +1883,21 @@ col
18831883
DROP TABLE t1;
18841884
End of 5.0 tests
18851885
CREATE TABLE t2 (a varchar(32), b int(11), c float, d double,
1886-
UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c));
1887-
CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b));
1888-
CREATE TABLE t3 (a varchar(32), b char(3), UNIQUE KEY a (a,b));
1886+
UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c)) charset utf8mb4;
1887+
CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b))
1888+
charset utf8mb4;
1889+
CREATE TABLE t3 (a varchar(32), b char(3), UNIQUE KEY a (a,b))
1890+
charset utf8mb4;
18891891
INSERT INTO t3 SELECT * FROM t1;
18901892
EXPLAIN
18911893
SELECT d FROM t1, t2
18921894
WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
18931895
ORDER BY t2.c LIMIT 1;
18941896
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1895-
1 SIMPLE t1 NULL ref a,b b 4 const 4 100.00 Using where; Using temporary; Using filesort
1896-
1 SIMPLE t2 NULL ref a,b,c a 40 test.t1.a,const 11 79.85 Using index condition
1897+
1 SIMPLE t1 NULL ref a,b b 13 const 3 100.00 Using where; Using temporary; Using filesort
1898+
1 SIMPLE t2 NULL ref a,b,c a 136 test.t1.a,const 11 79.85 Using index condition
18971899
Warnings:
1898-
Note 1003 /* select#1 */ select `test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = 'DE') and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`b` = 14) and (5.1 < `test`.`t2`.`c`)) order by `test`.`t2`.`c` limit 1
1900+
Note 1003 /* select#1 */ select `test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`b` = 14) and (5.1 < `test`.`t2`.`c`) and (`test`.`t1`.`b` = 'DE')) order by `test`.`t2`.`c` limit 1
18991901
SELECT d FROM t1, t2
19001902
WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
19011903
ORDER BY t2.c LIMIT 1;
@@ -1907,9 +1909,9 @@ WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
19071909
ORDER BY t2.c LIMIT 1;
19081910
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
19091911
1 SIMPLE t2 NULL range a,b,c c 5 NULL 420 26.43 Using index condition; Using where
1910-
1 SIMPLE t1 NULL ref a a 39 test.t2.a,const 10 100.00 Using index
1912+
1 SIMPLE t1 NULL ref a a 144 test.t2.a,const 10 100.00 Using index
19111913
Warnings:
1912-
Note 1003 /* select#1 */ select `test`.`t2`.`d` AS `d` from `test`.`t3` `t1` join `test`.`t2` where ((`test`.`t1`.`b` = 'DE') and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 14) and (5.1 < `test`.`t2`.`c`)) order by `test`.`t2`.`c` limit 1
1914+
Note 1003 /* select#1 */ select `test`.`t2`.`d` AS `d` from `test`.`t3` `t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 14) and (5.1 < `test`.`t2`.`c`) and (`test`.`t1`.`b` = 'DE')) order by `test`.`t2`.`c` limit 1
19131915
SELECT d FROM t3 AS t1, t2 AS t2
19141916
WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
19151917
ORDER BY t2.c LIMIT 1;
@@ -1919,7 +1921,7 @@ DROP TABLE t1,t2,t3;
19191921
#
19201922
# WL#1393 - Optimizing filesort with small limit
19211923
#
1922-
CREATE TABLE t1(f0 int auto_increment primary key, f1 int, f2 varchar(200));
1924+
CREATE TABLE t1(f0 int auto_increment primary key, f1 int, f2 varchar(200)) charset latin1;
19231925
INSERT INTO t1(f1, f2) VALUES
19241926
(0,"0"),(1,"1"),(2,"2"),(3,"3"),(4,"4"),(5,"5"),
19251927
(6,"6"),(7,"7"),(8,"8"),(9,"9"),(10,"10"),

0 commit comments

Comments
 (0)