MDEV-323: SHOW EXPLAIN: Plan produced by SHOW EXPLAIN loses 'UNION RESULT' line
- Make SHOW EXPLAIN code correctly print fake_select_lex: both in the case where it has not yet been executed, and when it has been executed.
This commit is contained in:
parent
a161c19bf2
commit
950dc8022e
@ -625,4 +625,38 @@ a + 1
|
||||
set debug_dbug='';
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-323: SHOW EXPLAIN: Plan produced by SHOW EXPLAIN loses
|
||||
# 'UNION RESULT' line on the way without saying that the plan was already deleted
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (4),(6);
|
||||
EXPLAIN
|
||||
SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
set debug_dbug='d,show_explain_probe_union_read';
|
||||
SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 );
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 )
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 )
|
||||
a
|
||||
set debug_dbug='';
|
||||
DROP TABLE t1;
|
||||
drop table t0;
|
||||
|
@ -634,6 +634,33 @@ DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-323: SHOW EXPLAIN: Plan produced by SHOW EXPLAIN loses
|
||||
--echo # 'UNION RESULT' line on the way without saying that the plan was already deleted
|
||||
--echo #
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (4),(6);
|
||||
|
||||
EXPLAIN
|
||||
SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 );
|
||||
|
||||
set debug_dbug='d,show_explain_probe_union_read';
|
||||
send
|
||||
SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 );
|
||||
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
|
||||
connection con1;
|
||||
reap;
|
||||
|
||||
set debug_dbug='';
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
## TODO: Test this: have several SHOW EXPLAIN requests be queued up for a
|
||||
## thread and served together.
|
||||
|
@ -4165,10 +4165,8 @@ int st_select_lex_unit::print_explain(select_result_sink *output,
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
Note: it could be that fake_select_lex->join == NULL still at this point
|
||||
*/
|
||||
if (fake_select_lex && !fake_select_lex->join)
|
||||
/* Note: fake_select_lex->join may be NULL or non-NULL at this point */
|
||||
if (fake_select_lex)
|
||||
{
|
||||
res= print_fake_select_lex_join(output, TRUE /* on the fly */,
|
||||
fake_select_lex, explain_flags);
|
||||
|
@ -720,6 +720,8 @@ bool st_select_lex_unit::exec()
|
||||
}
|
||||
}
|
||||
|
||||
DBUG_EXECUTE_IF("show_explain_probe_union_read",
|
||||
dbug_serve_apcs(thd, 1););
|
||||
/* Send result to 'result' */
|
||||
saved_error= TRUE;
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user