Skip to content

Commit 08f79bd

Browse files
committed
MDEV-11635 innodb.innodb_mysql test hangs
Copy and adapt the test from MySQL 5.7.17.
1 parent d6a1f9f commit 08f79bd

File tree

3 files changed

+121
-25
lines changed

3 files changed

+121
-25
lines changed

mysql-test/include/mix1.inc

Lines changed: 107 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ create table t2i (a int);
236236
insert into t2m values (5);
237237
insert into t2i values (5);
238238

239+
-- disable_query_log
240+
-- disable_result_log
241+
analyze table t1i;
242+
analyze table t1m;
243+
analyze table t2i;
244+
analyze table t2m;
245+
-- enable_result_log
246+
-- enable_query_log
247+
239248
# test with $engine_type
240249
select min(a) from t1i;
241250
select min(7) from t1i;
@@ -411,6 +420,13 @@ if ($test_foreign_keys)
411420
INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
412421
INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
413422

423+
-- disable_query_log
424+
-- disable_result_log
425+
ANALYZE TABLE t1;
426+
ANALYZE TABLE t2;
427+
-- enable_result_log
428+
-- enable_query_log
429+
414430
EXPLAIN
415431
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
416432
WHERE t1.name LIKE 'A%';
@@ -572,12 +588,22 @@ OPTIMIZE TABLE t1;
572588
SELECT COUNT(*) FROM t1;
573589
SELECT COUNT(*) FROM t1 WHERE acct_id=785;
574590

591+
-- disable_query_log
592+
-- disable_result_log
593+
ANALYZE TABLE t1;
594+
-- enable_result_log
595+
-- enable_query_log
596+
575597
EXPLAIN SELECT COUNT(*) FROM t1 WHERE stat_id IN (1,3) AND acct_id=785;
576598

577599
INSERT INTO t2 SELECT * FROM t1;
578600
OPTIMIZE TABLE t2;
579601

580-
EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785;
602+
-- disable_query_log
603+
-- disable_result_log
604+
ANALYZE TABLE t2;
605+
-- enable_result_log
606+
-- enable_query_log
581607

582608
DROP TABLE t1,t2;
583609

@@ -704,6 +730,13 @@ INSERT INTO t1(b,c) SELECT b,c FROM t2;
704730
UPDATE t2 SET c='2007-01-03';
705731
INSERT INTO t1(b,c) SELECT b,c FROM t2;
706732

733+
-- disable_query_log
734+
-- disable_result_log
735+
ANALYZE TABLE t1;
736+
ANALYZE TABLE t2;
737+
-- enable_result_log
738+
-- enable_query_log
739+
707740
set @@sort_buffer_size=8192;
708741

709742
SELECT COUNT(*) FROM t1;
@@ -793,6 +826,12 @@ INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1;
793826
INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1;
794827
INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1;
795828

829+
-- disable_query_log
830+
-- disable_result_log
831+
ANALYZE TABLE t1;
832+
-- enable_result_log
833+
-- enable_query_log
834+
796835
EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b;
797836
EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b;
798837
DROP TABLE t1;
@@ -855,6 +894,11 @@ CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY bkey (b)) ENGINE=InnoDB;
855894
INSERT INTO t1 VALUES (1,2),(3,2),(2,2),(4,2),(5,2),(6,2),(7,2),(8,2);
856895
INSERT INTO t1 SELECT a + 8, 2 FROM t1;
857896
INSERT INTO t1 SELECT a + 16, 1 FROM t1;
897+
-- disable_query_log
898+
-- disable_result_log
899+
ANALYZE TABLE t1;
900+
-- enable_result_log
901+
-- enable_query_log
858902
query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a;
859903
SELECT * FROM t1 WHERE b=2 ORDER BY a;
860904
query_vertical EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a;
@@ -868,6 +912,12 @@ INSERT INTO t2 VALUES (1,1,1),(3,1,1),(2,1,1),(4,1,1);
868912
INSERT INTO t2 SELECT a + 4, 1, 1 FROM t2;
869913
INSERT INTO t2 SELECT a + 8, 1, 1 FROM t2;
870914

915+
-- disable_query_log
916+
-- disable_result_log
917+
ANALYZE TABLE t2;
918+
-- enable_result_log
919+
-- enable_query_log
920+
871921
query_vertical EXPLAIN SELECT * FROM t2 WHERE b=1 ORDER BY a;
872922
SELECT * FROM t2 WHERE b=1 ORDER BY a;
873923
query_vertical EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY a;
@@ -959,7 +1009,7 @@ SELECT * FROM t1 WHERE b=20 FOR UPDATE;
9591009

9601010
--connect (conn2, localhost, root,,test)
9611011

962-
# This statement gives a "failed: 1205: Lock wait timeout exceeded; try
1012+
# This statement gives a "failed: 1205: Lock wait timeout exceeded; try
9631013
# restarting transaction" message when the bug is present.
9641014
START TRANSACTION;
9651015
SELECT * FROM t1 WHERE b=10 ORDER BY A FOR UPDATE;
@@ -984,6 +1034,12 @@ CREATE TABLE t1(
9841034

9851035
INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
9861036

1037+
-- disable_query_log
1038+
-- disable_result_log
1039+
ANALYZE TABLE t1;
1040+
-- enable_result_log
1041+
-- enable_query_log
1042+
9871043
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d;
9881044
SELECT c,b,d FROM t1 GROUP BY c,b,d;
9891045
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
@@ -1004,6 +1060,12 @@ DROP TABLE t1;
10041060
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), INDEX b (b)) ENGINE=InnoDB;
10051061
INSERT INTO t1(a,b) VALUES (1,1), (2,2), (3,2);
10061062

1063+
-- disable_query_log
1064+
-- disable_result_log
1065+
ANALYZE TABLE t1;
1066+
-- enable_result_log
1067+
-- enable_query_log
1068+
10071069
#The two queries below should produce different results, but they don't.
10081070
query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
10091071
SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
@@ -1087,6 +1149,12 @@ CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB;
10871149
INSERT INTO t1 VALUES
10881150
(191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2);
10891151

1152+
-- disable_query_log
1153+
-- disable_result_log
1154+
ANALYZE TABLE t1;
1155+
-- enable_result_log
1156+
-- enable_query_log
1157+
10901158
EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
10911159
SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
10921160

@@ -1115,12 +1183,13 @@ CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY (a), KEY t1_b (b))
11151183
INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1);
11161184
INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1;
11171185

1118-
# should be range access
1186+
-- disable_query_log
1187+
-- disable_result_log
1188+
ANALYZE TABLE t1;
1189+
-- enable_result_log
1190+
-- enable_query_log
11191191

1120-
#
1121-
# InnoDB uses "where", while xtradb "index condition"
1122-
#
1123-
--replace_regex /where/index condition/
1192+
# should be range access
11241193
EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;
11251194

11261195
# should produce '8 7 6 5 4' for a
@@ -1514,6 +1583,12 @@ INSERT INTO t1 VALUES
15141583
(4,1,3,'pk',NULL),(5,1,3,'c2',NULL),
15151584
(2,1,4,'c_extra',NULL),(3,1,4,'c_extra',NULL);
15161585

1586+
-- disable_query_log
1587+
-- disable_result_log
1588+
ANALYZE TABLE t1;
1589+
-- enable_result_log
1590+
-- enable_query_log
1591+
15171592
EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
15181593

15191594
SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
@@ -1531,6 +1606,12 @@ CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, KEY (c3), KEY (c2, c3))
15311606
ENGINE=$engine_type;
15321607
INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2);
15331608

1609+
-- disable_query_log
1610+
-- disable_result_log
1611+
ANALYZE TABLE t1;
1612+
-- enable_result_log
1613+
-- enable_query_log
1614+
15341615
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
15351616
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
15361617
EXPLAIN
@@ -1544,6 +1625,12 @@ CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3))
15441625
ENGINE=$engine_type;
15451626
INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2);
15461627

1628+
-- disable_query_log
1629+
-- disable_result_log
1630+
ANALYZE TABLE t1;
1631+
-- enable_result_log
1632+
-- enable_query_log
1633+
15471634
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
15481635
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
15491636
EXPLAIN
@@ -1558,6 +1645,12 @@ CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2),
15581645
ENGINE=$engine_type;
15591646
INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2);
15601647

1648+
-- disable_query_log
1649+
-- disable_result_log
1650+
ANALYZE TABLE t1;
1651+
-- enable_result_log
1652+
-- enable_query_log
1653+
15611654
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
15621655
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
15631656
EXPLAIN
@@ -1585,6 +1678,13 @@ CREATE TABLE t2 (
15851678
insert into t1 values (0),(1),(2),(3),(4);
15861679
insert into t2 select A.a + 10 *B.a, 1, 'filler' from t1 A, t1 B;
15871680

1681+
-- disable_query_log
1682+
-- disable_result_log
1683+
analyze table t1;
1684+
analyze table t2;
1685+
-- enable_result_log
1686+
-- enable_query_log
1687+
15881688
explain select * from t1, t2 where t2.a=t1.a and t2.b + 1;
15891689
select * from t1, t2 where t2.a=t1.a and t2.b + 1;
15901690

mysql-test/suite/innodb/r/innodb_mysql.result

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
set global innodb_support_xa=default;
2-
Warnings:
3-
Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
4-
set session innodb_support_xa=default;
5-
Warnings:
6-
Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
71
SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB;
82
drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4;
93
drop procedure if exists p1;
@@ -614,9 +608,6 @@ OPTIMIZE TABLE t2;
614608
Table Op Msg_type Msg_text
615609
test.t2 optimize note Table does not support optimize, doing recreate + analyze instead
616610
test.t2 optimize status OK
617-
EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785;
618-
id select_type table type possible_keys key key_len ref rows Extra
619-
1 SIMPLE t2 range idx1,idx2 idx1 9 NULL 2 Using where; Using index
620611
DROP TABLE t1,t2;
621612
create table t1(a int) engine=innodb;
622613
alter table t1 comment '123';
@@ -1433,7 +1424,7 @@ INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1);
14331424
INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1;
14341425
EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;
14351426
id select_type table type possible_keys key key_len ref rows Extra
1436-
1 SIMPLE t1 range t1_b t1_b 5 NULL 8 Using index condition
1427+
1 SIMPLE t1 range t1_b t1_b 5 NULL 8 Using where
14371428
SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;
14381429
a b c
14391430
8 1 1
@@ -2278,7 +2269,7 @@ INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6);
22782269
INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
22792270
INSERT INTO t3 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106);
22802271
INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
2281-
UPDATE t1, t2 SET t1.a = t1.a + 100, t2.b = t1.a + 10
2272+
UPDATE t2 straight_join t1 SET t1.a = t1.a + 100, t2.b = t1.a + 10
22822273
WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b;
22832274
SELECT * FROM t2;
22842275
a b
@@ -2287,7 +2278,7 @@ a b
22872278
3 13
22882279
4 14
22892280
5 5
2290-
UPDATE t3, t4 SET t3.a = t3.a + 100, t4.b = t3.a + 10
2281+
UPDATE t4 straight_join t3 SET t3.a = t3.a + 100, t4.b = t3.a + 10
22912282
WHERE t3.a BETWEEN 2 AND 4 AND t4.a = t3.b - 100;
22922283
SELECT * FROM t4;
22932284
a b
@@ -2338,6 +2329,9 @@ INSERT INTO t1 SELECT c1+1000,c2+1000,c3+1000 from t1;
23382329
INSERT INTO t1 SELECT c1+10000,c2+10000,c3+10000 from t1;
23392330
INSERT INTO t1 SELECT c1+100000,c2+100000,c3+100000 from t1;
23402331
INSERT INTO t1 SELECT c1+1000000,c2+1000000,c3+1000000 from t1;
2332+
ANALYZE TABLE t1;
2333+
Table Op Msg_type Msg_text
2334+
test.t1 analyze status OK
23412335
SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3;
23422336
c1 c2 c3
23432337
EXPLAIN SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3;

mysql-test/suite/innodb/t/innodb_mysql.test

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
-- source include/have_innodb.inc
1414
let $engine_type= InnoDB;
1515
let $other_engine_type= MEMORY;
16-
# InnoDB does support FOREIGN KEYFOREIGN KEYs
16+
# InnoDB does support FOREIGN KEYs
1717
let $test_foreign_keys= 1;
18-
set global innodb_support_xa=default;
19-
set session innodb_support_xa=default;
2018
--source include/mix1.inc
2119

2220
--disable_warnings
@@ -359,12 +357,16 @@ INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
359357
INSERT INTO t3 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106);
360358
INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
361359

362-
UPDATE t1, t2 SET t1.a = t1.a + 100, t2.b = t1.a + 10
360+
# Because t1.a changes and t2.b changes based on t1.a, the result
361+
# depends on join order, so STRAIGHT_JOIN is used to have it repeatable.
362+
UPDATE t2 straight_join t1 SET t1.a = t1.a + 100, t2.b = t1.a + 10
363363
WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b;
364364
--sorted_result
365365
SELECT * FROM t2;
366366

367-
UPDATE t3, t4 SET t3.a = t3.a + 100, t4.b = t3.a + 10
367+
# Because t1.a changes and t2.b changes based on t1.a, the result
368+
# depends on join order, so STRAIGHT_JOIN is used to have it repeatable.
369+
UPDATE t4 straight_join t3 SET t3.a = t3.a + 100, t4.b = t3.a + 10
368370
WHERE t3.a BETWEEN 2 AND 4 AND t4.a = t3.b - 100;
369371
--sorted_result
370372
SELECT * FROM t4;
@@ -420,7 +422,7 @@ INSERT INTO t1 SELECT c1+1000,c2+1000,c3+1000 from t1;
420422
INSERT INTO t1 SELECT c1+10000,c2+10000,c3+10000 from t1;
421423
INSERT INTO t1 SELECT c1+100000,c2+100000,c3+100000 from t1;
422424
INSERT INTO t1 SELECT c1+1000000,c2+1000000,c3+1000000 from t1;
423-
425+
ANALYZE TABLE t1;
424426
# query and no rows will match the c1 condition, whereas all will match c3
425427
SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3;
426428

0 commit comments

Comments
 (0)