mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Fix typo bug in UNION handling, add tests for SHOW EXPLAIN for UNION.
This commit is contained in:
@@ -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
|
1 SIMPLE t1 range a a 5 NULL 10 Using where
|
||||||
max(c)
|
max(c)
|
||||||
9
|
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';
|
set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_sort_keys=on';
|
||||||
explain select max(c) from t1 where a < 10;
|
explain select max(c) from t1 where a < 10;
|
||||||
show explain for $thr2;
|
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
|
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
|
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
|
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;
|
drop table t0,t1;
|
||||||
|
@@ -87,7 +87,9 @@ evalp show explain for $thr2;
|
|||||||
connection con1;
|
connection con1;
|
||||||
reap;
|
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';
|
set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_sort_keys=on';
|
||||||
send explain select max(c) from t1 where a < 10;
|
send explain select max(c) from t1 where a < 10;
|
||||||
connection default;
|
connection default;
|
||||||
@@ -95,6 +97,28 @@ connection default;
|
|||||||
evalp show explain for $thr2;
|
evalp show explain for $thr2;
|
||||||
connection con1;
|
connection con1;
|
||||||
reap;
|
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
|
# Let's try with a subquery
|
||||||
|
|
||||||
|
@@ -3667,7 +3667,11 @@ int st_select_lex_unit::print_explain(select_result_sink *output)
|
|||||||
if ((res= sl->print_explain(output)))
|
if ((res= sl->print_explain(output)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!fake_select_lex->join)
|
|
||||||
|
/*
|
||||||
|
Note: it could be that fake_select_lex->join == NULL still at this point
|
||||||
|
*/
|
||||||
|
if (fake_select_lex && !fake_select_lex->join)
|
||||||
{
|
{
|
||||||
res= print_fake_select_lex_join(output, TRUE /* on the fly */,
|
res= print_fake_select_lex_join(output, TRUE /* on the fly */,
|
||||||
fake_select_lex, 0 /* flags */);
|
fake_select_lex, 0 /* flags */);
|
||||||
|
Reference in New Issue
Block a user