summaryrefslogtreecommitdiff
path: root/mysql-test/t/show_explain_non_select.test
blob: 21b1673914189279e0611a73a6ed0f04e9b77efd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#
# SHOW EXPLAIN tests for non-select subqueries
#
--source include/have_debug.inc
--source include/have_innodb.inc
--source include/not_embedded.inc

--disable_warnings
drop table if exists t0, t1;
--enable_warnings

SET @old_debug= @@session.debug;
set debug_sync='RESET';

# 
# Setup two threads and their ids
#
let $thr1=`select connection_id()`;
connect (con2, localhost, root,,);
connection con2;
let $thr2=`select connection_id()`;
connection default;

# 
# Create tables
# 
create table t0 (a int) engine=myisam;
insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);

create table t1 (a int, b int, filler char(100), key(a), key(b));
insert into t1 
select A.a+10*B.a + 10*C.a, A.a+10*B.a + 10*C.a, 'filler' 
from t0 A, t0 B, t0 C;

let $wait_condition= select State='show_explain_trap' from information_schema.processlist where id=$thr2;

--echo #
--echo # Test SHOW EXPLAIN for single-table DELETE
--echo #
connection con2;
set debug_dbug='+d,show_explain_probe_delete_exec_start';
send delete from t1 where a<10 and b+1>1000;

connection default;
--source include/wait_condition.inc
evalp show explain for $thr2;
connection con2;
reap;

--echo #
--echo # Test SHOW EXPLAIN for multi-table DELETE
--echo #
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_do_select';
send delete t1 from t1, t0 where t0.a=t1.a and t1.b +1 > 1000;
connection default;
--source include/wait_condition.inc
evalp show explain for $thr2;
connection con2;
reap;

--echo #
--echo # Test SHOW EXPLAIN for single-table UPDATE
--echo #
connection con2;
set debug_dbug='+d,show_explain_probe_update_exec_start';
send update t1 set filler='filler-data-2' where a<10 and b+1>1000;

connection default;
--source include/wait_condition.inc
evalp show explain for $thr2;
connection con2;
reap;

drop table t0,t1;

set debug_dbug=@old_debug;
set debug_sync='RESET';