1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fix typo bug in UNION handling, add tests for SHOW EXPLAIN for UNION.

This commit is contained in:
Sergey Petrunya
2011-10-27 21:34:41 +04:00
parent b7a340eeb0
commit ba09d25abc
3 changed files with 59 additions and 2 deletions

View File

@ -28,6 +28,8 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 10 Using where
max(c)
9
# We can catch EXPLAIN, too.
set @show_expl_tmp= @@optimizer_switch;
set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_sort_keys=on';
explain select max(c) from t1 where a < 10;
show explain for $thr2;
@ -35,4 +37,31 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 10 Using index condition; Rowid-ordered scan
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 10 Using index condition; Rowid-ordered scan
set optimizer_switch= @show_expl_tmp;
# UNION, first branch
set @show_explain_probe_select_id=1;
set debug='d,show_explain_probe_1';
explain select a from t0 A union select a+1 from t0 B;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10
2 UNION B ALL NULL NULL NULL NULL 10
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10
2 UNION B ALL NULL NULL NULL NULL 10
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
# UNION, second branch
set @show_explain_probe_select_id=1;
set debug='d,show_explain_probe_1';
explain select a from t0 A union select a+1 from t0 B;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10
2 UNION B ALL NULL NULL NULL NULL 10
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10
2 UNION B ALL NULL NULL NULL NULL 10
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
drop table t0,t1;

View File

@ -87,7 +87,9 @@ evalp show explain for $thr2;
connection con1;
reap;
# We can catch EXPLAIN, too.
--echo # We can catch EXPLAIN, too.
set @show_expl_tmp= @@optimizer_switch;
set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_sort_keys=on';
send explain select max(c) from t1 where a < 10;
connection default;
@ -95,6 +97,28 @@ connection default;
evalp show explain for $thr2;
connection con1;
reap;
set optimizer_switch= @show_expl_tmp;
--echo # UNION, first branch
set @show_explain_probe_select_id=1;
set debug='d,show_explain_probe_1';
send explain select a from t0 A union select a+1 from t0 B;
connection default;
--source include/wait_condition.inc
evalp show explain for $thr2;
connection con1;
reap;
--echo # UNION, second branch
set @show_explain_probe_select_id=1;
set debug='d,show_explain_probe_1';
send explain select a from t0 A union select a+1 from t0 B;
connection default;
--source include/wait_condition.inc
evalp show explain for $thr2;
connection con1;
reap;
# Let's try with a subquery