# TestExplainCartesianJoin drop table if exists t; create table t (v int); explain format = 'brief' select * from t t1, t t2; explain format = 'brief' select * from t t1 where exists (select 1 from t t2 where t2.v > t1.v); explain format = 'brief' select * from t t1 where exists (select 1 from t t2 where t2.v in (t1.v+1, t1.v+2)); explain format = 'brief' select * from t t1, t t2 where t1.v = t2.v; # TestExplainWrite drop table if exists t; create table t (a int); --disable_result_log explain analyze insert into t select 1; --enable_result_log select * from t; --disable_result_log explain analyze update t set a=2 where a=1; --enable_result_log select * from t; --disable_result_log explain format = 'brief' insert into t select 1; --enable_result_log select * from t; --disable_result_log explain analyze insert into t select 1; explain analyze replace into t values (3); --enable_result_log select * from t order by a; # TestExplainStatementsSummary desc format='brief' select * from information_schema.statements_summary; desc format='brief' select * from information_schema.statements_summary where digest is null; desc format='brief' select * from information_schema.statements_summary where digest = 'abcdefg'; desc format='brief' select * from information_schema.statements_summary where digest in ('a','b','c'); # TestFix29401 drop table if exists tt123; CREATE TABLE tt123 ( id int(11) NOT NULL, a bigint(20) DEFAULT NULL, b char(20) DEFAULT NULL, c datetime DEFAULT NULL, d double DEFAULT NULL, e json DEFAULT NULL, f decimal(40,6) DEFAULT NULL, PRIMARY KEY (id) /*T![clustered_index] CLUSTERED */, KEY a (a), KEY b (b), KEY c (c), KEY d (d), KEY f (f) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; explain format='brief' select /*+ inl_hash_join(t1) */ * from tt123 t1 join tt123 t2 on t1.b=t2.e; # TestIssue35105 drop table if exists t; create table t (a int primary key); insert into t values (2); set @@tidb_constraint_check_in_place=1; -- error 1062 explain analyze insert into t values (1), (2), (3); select * from t; set @@tidb_constraint_check_in_place=DEFAULT; # TestExplainFormatPlanCache drop table if exists t; create table t(a int); set @@session.tidb_enable_non_prepared_plan_cache = 1; select * from t limit 1; select * from t limit 1; explain format = 'plan_cache' select * from (select * from t) t1 limit 1; show warnings; explain format = 'plan_cache' select * from (select * from t) t1 limit 1; select @@last_plan_from_cache; --disable_result_log explain analyze format = 'plan_cache' select * from (select * from t) t1 limit 1; --enable_result_log show warnings; --disable_result_log explain analyze format = 'plan_cache' select * from (select * from t) t1 limit 1; --enable_result_log select @@last_plan_from_cache; explain format = 'plan_cache' select * from t; show warnings; explain format = 'plan_cache' select * from t; select @@last_plan_from_cache; --disable_result_log explain analyze format = 'plan_cache' select * from t; --enable_result_log show warnings; --disable_result_log explain analyze format = 'plan_cache' select * from t; --enable_result_log select @@last_plan_from_cache; explain select * from t; select @@last_plan_from_cache; explain format = 'brief' select * from t; select @@last_plan_from_cache; explain format = 'dot' select * from t; select @@last_plan_from_cache; explain format = 'hint' select * from t; select @@last_plan_from_cache; explain format = 'row' select * from t; select @@last_plan_from_cache; explain format = 'verbose' select * from t; select @@last_plan_from_cache; explain format = 'traditional' select * from t; select @@last_plan_from_cache; explain format = 'binary' select * from t; select @@last_plan_from_cache; explain format = 'tidb_json' select * from t; select @@last_plan_from_cache; explain format = 'cost_trace' select * from t; select @@last_plan_from_cache; set @@session.tidb_enable_non_prepared_plan_cache = DEFAULT; # TestExplainPrivileges drop table if exists t; drop view if exists v; drop user if exists 'explain'@'%'; create table t (id int); create view v as select * from t; create user 'explain'@'%'; grant select on executor__explain.v to 'explain'@'%'; connect (conn1, localhost, explain,,); show databases; use executor__explain; select * from v; -- error 1345 explain format = 'brief' select * from v; connection default; grant show view on executor__explain.v to 'explain'@'%'; connection conn1; explain format = 'brief' select * from v; connection default; revoke select on executor__explain.v from 'explain'@'%'; connection conn1; -- error 1142 explain format = 'brief' select * from v; connection default; create table t1 (i int); create table t2 (j int); create table t3 (k int, secret int); create view v1 as select * from t1; create view v2 as select * from v1, t2; create view v3 as select k from t3; grant select, show view on executor__explain.v2 to 'explain'@'%'; grant show view on executor__explain.v1 to 'explain'@'%'; grant select, show view on executor__explain.t3 to 'explain'@'%'; grant select, show view on executor__explain.v3 to 'explain'@'%'; connection conn1; -- error 1142 explain select * from v1; -- error 1345 explain select * from v2; explain select * from t3; explain select * from v3; disconnect conn1;