1drop table if exists t0, t1;
2SET @old_debug= @@session.debug;
3set debug_sync='RESET';
4connect  con2, localhost, root,,;
5connection con2;
6connection default;
7create table t0 (a int) engine=myisam;
8insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);
9create table t1 (a int, b int, filler char(100), key(a), key(b));
10insert into t1
11select A.a+10*B.a + 10*C.a, A.a+10*B.a + 10*C.a, 'filler'
12from t0 A, t0 B, t0 C;
13#
14# Test SHOW EXPLAIN for single-table DELETE
15#
16connection con2;
17SET debug_dbug='+d,show_explain_probe_delete_exec_start';
18delete from t1 where a<10 and b+1>1000;
19connection default;
20show explain for $thr2;
21id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
221	SIMPLE	t1	range	a	a	5	NULL	1	Using where
23Warnings:
24Note	1003	delete from t1 where a<10 and b+1>1000
25connection con2;
26#
27# Test SHOW EXPLAIN for multi-table DELETE
28#
29set @show_explain_probe_select_id=1;
30SET debug_dbug='+d,show_explain_probe_do_select';
31delete t1 from t1, t0 where t0.a=t1.a and t1.b +1 > 1000;
32connection default;
33show explain for $thr2;
34id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
351	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	8	Using where
361	SIMPLE	t1	ref	a	a	5	test.t0.a	4	Using where
37Warnings:
38Note	1003	delete t1 from t1, t0 where t0.a=t1.a and t1.b +1 > 1000
39connection con2;
40#
41# Test SHOW EXPLAIN for single-table UPDATE
42#
43connection con2;
44SET debug_dbug='+d,show_explain_probe_update_exec_start';
45update t1 set filler='filler-data-2' where a<10 and b+1>1000;
46connection default;
47show explain for $thr2;
48id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
491	SIMPLE	t1	range	a	a	5	NULL	1	Using where
50Warnings:
51Note	1003	update t1 set filler='filler-data-2' where a<10 and b+1>1000
52connection con2;
53drop table t0,t1;
54SET debug_dbug=@old_debug;
55set debug_sync='RESET';
56