1 -- source include/have_log_bin.inc
2 -- source include/have_innodb.inc
3 -- source include/not_binlog_format_row.inc
6 --echo # Bug #39022: Mysql randomly crashing in lock_sec_rec_cons_read_sees
9 CREATE TABLE t1(a TINYINT NOT NULL,b TINYINT,PRIMARY KEY(b)) ENGINE=innodb;
10 CREATE TABLE t2(d TINYINT NOT NULL,UNIQUE KEY(d)) ENGINE=innodb;
11 INSERT INTO t1 VALUES (13,0),(8,1),(9,2),(6,3),
12 (11,5),(11,6),(7,7),(7,8),(4,9),(6,10),(3,11),(11,12),
14 INSERT INTO t2 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
17 connect (thread1, localhost, root,,);
18 connect (thread2, localhost, root,,);
26 REPLACE INTO t2 VALUES (-17);
27 SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE;
31 REPLACE INTO t1(a,b) VALUES (67,20);
37 REPLACE INTO t1(a,b) VALUES (65,-50);
38 REPLACE INTO t2 VALUES (-91);
40 SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE; #waits
45 --echo # should not crash
46 --error ER_LOCK_DEADLOCK
47 SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE; #crashes
54 --source include/wait_until_disconnected.inc
59 --source include/wait_until_disconnected.inc