From 45503698c13c55a6c21e02f4422bd3a4bcb02fd9 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Thu, 21 Jun 2012 22:15:13 +0400 Subject: [PATCH] Test that SHOW EXPLAIN will print 'Distinct'. --- mysql-test/r/show_explain.result | 33 +++++++++++++++++++++++++++++++ mysql-test/t/show_explain.test | 34 ++++++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/show_explain.result b/mysql-test/r/show_explain.result index 1c18112a7e5..07bcb29a7ea 100644 --- a/mysql-test/r/show_explain.result +++ b/mysql-test/r/show_explain.result @@ -695,4 +695,37 @@ WHERE a < ALL ( SELECT b FROM t1, t2 WHERE a = b ) a b set debug_dbug=''; DROP TABLE t1, t2; +# +# Test that SHOW EXPLAIN will print 'Distinct'. +# +CREATE TABLE t1 (a int(10) unsigned not null primary key,b int(10) unsigned); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1); +CREATE TABLE t3 (a int(10) unsigned, key(A), b text); +INSERT INTO t3 VALUES (1,'1'),(2,'2'); +create temporary table t4 select * from t3; +insert into t3 select * from t4; +insert into t4 select * from t3; +insert into t3 select * from t4; +insert into t4 select * from t3; +insert into t3 select * from t4; +insert into t4 select * from t3; +insert into t3 select * from t4; +explain select distinct t1.a from t1,t3 where t1.a=t3.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 Using index; Using temporary +1 SIMPLE t3 ref a a 5 test.t1.a 7 Using index; Distinct +set @show_explain_probe_select_id=1; +set debug_dbug='d,show_explain_probe_join_exec_start'; +select distinct t1.a from t1,t3 where t1.a=t3.a; +show explain for $thr2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 Using index; Using temporary +1 SIMPLE t3 ref a a 5 test.t1.a 7 Using index; Distinct +Warnings: +Note 1003 select distinct t1.a from t1,t3 where t1.a=t3.a +a +1 +2 +set debug_dbug=''; +drop table t1,t3,t4; drop table t0; diff --git a/mysql-test/t/show_explain.test b/mysql-test/t/show_explain.test index d7e5a0bc6fd..ffd2c25dfd9 100644 --- a/mysql-test/t/show_explain.test +++ b/mysql-test/t/show_explain.test @@ -692,11 +692,41 @@ evalp show explain for $thr2; connection con1; reap; - set debug_dbug=''; - DROP TABLE t1, t2; +--echo # +--echo # Test that SHOW EXPLAIN will print 'Distinct'. +--echo # +CREATE TABLE t1 (a int(10) unsigned not null primary key,b int(10) unsigned); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1); + +CREATE TABLE t3 (a int(10) unsigned, key(A), b text); +INSERT INTO t3 VALUES (1,'1'),(2,'2'); + +create temporary table t4 select * from t3; +insert into t3 select * from t4; +insert into t4 select * from t3; +insert into t3 select * from t4; +insert into t4 select * from t3; +insert into t3 select * from t4; +insert into t4 select * from t3; +insert into t3 select * from t4; +explain select distinct t1.a from t1,t3 where t1.a=t3.a; + +set @show_explain_probe_select_id=1; +set debug_dbug='d,show_explain_probe_join_exec_start'; +--send +select distinct t1.a from t1,t3 where t1.a=t3.a; +connection default; +--source include/wait_condition.inc +evalp show explain for $thr2; + +connection con1; +reap; +set debug_dbug=''; + +drop table t1,t3,t4; ## TODO: Test this: have several SHOW EXPLAIN requests be queued up for a ## thread and served together.