mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-305: SHOW EXPLAIN: ref returned by SHOW EXPLAIN is different from the normal EXPLAIN ('const' vs empty string)
- The problem was that create_ref_for_key() would act differently, depending on whether we're running EXPLAIN or the actual query. - As the first step, fixed the EXPLAIN printout not to depend on actions in create_ref_for_key().
This commit is contained in:
@ -448,7 +448,7 @@ WHERE pk= (SELECT MAX(pk) FROM t2 WHERE pk = 3)
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 20 Using where
|
||||
2 SUBQUERY t2 const PRIMARY PRIMARY 4 1 Using where
|
||||
2 SUBQUERY t2 const PRIMARY PRIMARY 4 const 1 Using where
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
Warnings:
|
||||
Note 1003 SELECT * FROM t2 WHERE a =
|
||||
@ -521,9 +521,7 @@ INSERT INTO t2 VALUES
|
||||
(1,5),(2,4),(3,6),(4,9),(5,2),(6,8),(7,4),(8,8),(9,0),(10,43),
|
||||
(11,23),(12,3),(13,45),(14,16),(15,2),(16,33),(17,2),(18,5),(19,9),(20,2);
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug='d,show_explain_probe_join_exec_end';
|
||||
Warnings:
|
||||
Warning 1287 The syntax '@@debug' is deprecated and will be removed in MariaDB 5.6. Please use '@@debug_dbug' instead
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
SELECT * FROM t2 WHERE (5, 78) IN (SELECT `a1`, MAX(`a1`) FROM t2 GROUP BY `a1`);
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -531,8 +529,25 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
Warnings:
|
||||
Note 1003 SELECT * FROM t2 WHERE (5, 78) IN (SELECT `a1`, MAX(`a1`) FROM t2 GROUP BY `a1`)
|
||||
pk a1
|
||||
set debug='';
|
||||
Warnings:
|
||||
Warning 1287 The syntax '@@debug' is deprecated and will be removed in MariaDB 5.6. Please use '@@debug_dbug' instead
|
||||
set debug_dbug='';
|
||||
DROP TABLE t2;
|
||||
drop table t0,t1;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-305: SHOW EXPLAIN: ref returned by SHOW EXPLAIN is different from the normal EXPLAIN ('const' vs empty string)
|
||||
#
|
||||
CREATE TABLE t1(a INT, KEY(a));
|
||||
INSERT INTO t1 VALUES (3),(1),(5),(1);
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
SELECT 'test' FROM t1 WHERE a=1;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 1 Using index
|
||||
Warnings:
|
||||
Note 1003 SELECT 'test' FROM t1 WHERE a=1
|
||||
test
|
||||
test
|
||||
test
|
||||
set debug_dbug='';
|
||||
DROP TABLE t1;
|
||||
drop table t0;
|
||||
|
@ -508,7 +508,7 @@ INSERT INTO t2 VALUES
|
||||
(11,23),(12,3),(13,45),(14,16),(15,2),(16,33),(17,2),(18,5),(19,9),(20,2);
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
send
|
||||
SELECT * FROM t2 WHERE (5, 78) IN (SELECT `a1`, MAX(`a1`) FROM t2 GROUP BY `a1`);
|
||||
connection default;
|
||||
@ -516,10 +516,33 @@ connection default;
|
||||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug='';
|
||||
set debug_dbug='';
|
||||
|
||||
DROP TABLE t2;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-305: SHOW EXPLAIN: ref returned by SHOW EXPLAIN is different from the normal EXPLAIN ('const' vs empty string)
|
||||
--echo #
|
||||
CREATE TABLE t1(a INT, KEY(a));
|
||||
INSERT INTO t1 VALUES (3),(1),(5),(1);
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
|
||||
send SELECT 'test' FROM t1 WHERE a=1;
|
||||
connection default;
|
||||
--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.
|
||||
@ -527,4 +550,4 @@ DROP TABLE t2;
|
||||
## TODO: SHOW EXPLAIN while the primary query is running EXPLAIN EXTENDED/PARTITIONS
|
||||
##
|
||||
|
||||
drop table t0,t1;
|
||||
drop table t0;
|
||||
|
Reference in New Issue
Block a user