mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
- Testing: add DBUG_EXECUTE_IF("show_explain_probe_2"... which fires
only for selects with given select_id. - Steps towards making SHOW EXPLAIN work for UNIONs.
This commit is contained in:
@ -14,6 +14,7 @@ show explain for $thr2;
|
|||||||
ERROR HY000: Error when executing command SHOW EXPLAIN: Target is not running EXPLAINable command
|
ERROR HY000: Error when executing command SHOW EXPLAIN: Target is not running EXPLAINable command
|
||||||
show explain for $thr1;
|
show explain for $thr1;
|
||||||
ERROR HY000: Error when executing command SHOW EXPLAIN: Target is not running EXPLAINable command
|
ERROR HY000: Error when executing command SHOW EXPLAIN: Target is not running EXPLAINable command
|
||||||
|
set @show_explain_probe_select_id=1;
|
||||||
set debug='d,show_explain_probe_1';
|
set debug='d,show_explain_probe_1';
|
||||||
select count(*) from t1 where a < 100000;
|
select count(*) from t1 where a < 100000;
|
||||||
show explain for $thr2;
|
show explain for $thr2;
|
||||||
@ -21,7 +22,6 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||||||
1 SIMPLE t1 index a a 5 NULL 1000 Using where; Using index
|
1 SIMPLE t1 index a a 5 NULL 1000 Using where; Using index
|
||||||
count(*)
|
count(*)
|
||||||
1000
|
1000
|
||||||
set debug='d,show_explain_probe_1';
|
|
||||||
select max(c) from t1 where a < 10;
|
select max(c) from t1 where a < 10;
|
||||||
show explain for $thr2;
|
show explain for $thr2;
|
||||||
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
|
||||||
@ -29,7 +29,6 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||||||
max(c)
|
max(c)
|
||||||
9
|
9
|
||||||
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';
|
||||||
set debug='d,show_explain_probe_1';
|
|
||||||
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;
|
||||||
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,6 +1,8 @@
|
|||||||
#
|
#
|
||||||
# Tests for SHOW EXPLAIN FOR functionality
|
# Tests for SHOW EXPLAIN FOR functionality
|
||||||
#
|
#
|
||||||
|
--source include/have_debug.inc
|
||||||
|
|
||||||
--disable_warnings
|
--disable_warnings
|
||||||
drop table if exists t0, t1;
|
drop table if exists t0, t1;
|
||||||
--enable_warnings
|
--enable_warnings
|
||||||
@ -45,6 +47,7 @@ let $wait_condition= select State='show_explain_trap' from information_schema.pr
|
|||||||
# Test SHOW EXPLAIN for simple queries
|
# Test SHOW EXPLAIN for simple queries
|
||||||
#
|
#
|
||||||
connection con1;
|
connection con1;
|
||||||
|
set @show_explain_probe_select_id=1;
|
||||||
set debug='d,show_explain_probe_1';
|
set debug='d,show_explain_probe_1';
|
||||||
send select count(*) from t1 where a < 100000;
|
send select count(*) from t1 where a < 100000;
|
||||||
|
|
||||||
@ -55,7 +58,6 @@ connection con1;
|
|||||||
reap;
|
reap;
|
||||||
|
|
||||||
|
|
||||||
set debug='d,show_explain_probe_1';
|
|
||||||
send select max(c) from t1 where a < 10;
|
send select max(c) from t1 where a < 10;
|
||||||
connection default;
|
connection default;
|
||||||
--source include/wait_condition.inc
|
--source include/wait_condition.inc
|
||||||
@ -65,7 +67,6 @@ reap;
|
|||||||
|
|
||||||
# We can catch EXPLAIN, too.
|
# We can catch EXPLAIN, too.
|
||||||
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';
|
||||||
set debug='d,show_explain_probe_1';
|
|
||||||
send explain select max(c) from t1 where a < 10;
|
send explain select max(c) from t1 where a < 10;
|
||||||
connection default;
|
connection default;
|
||||||
--source include/wait_condition.inc
|
--source include/wait_condition.inc
|
||||||
@ -73,6 +74,8 @@ evalp show explain for $thr2;
|
|||||||
connection con1;
|
connection con1;
|
||||||
reap;
|
reap;
|
||||||
|
|
||||||
|
# Let's try with a subquery
|
||||||
|
|
||||||
|
|
||||||
## TODO: Test this: multiple SHOW EXPLAIN calls in course of running of one select
|
## TODO: Test this: multiple SHOW EXPLAIN calls in course of running of one select
|
||||||
##
|
##
|
||||||
|
@ -3871,7 +3871,7 @@ longlong Item_func_sleep::val_int()
|
|||||||
|
|
||||||
#define extra_size sizeof(double)
|
#define extra_size sizeof(double)
|
||||||
|
|
||||||
static user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
|
user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
|
||||||
bool create_if_not_exists)
|
bool create_if_not_exists)
|
||||||
{
|
{
|
||||||
user_var_entry *entry;
|
user_var_entry *entry;
|
||||||
|
@ -3474,6 +3474,8 @@ class user_var_entry
|
|||||||
DTCollation collation;
|
DTCollation collation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
|
||||||
|
bool create_if_not_exists);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Unique -- class for unique (removing of duplicates).
|
Unique -- class for unique (removing of duplicates).
|
||||||
|
@ -3529,7 +3529,8 @@ void st_select_lex::set_explain_type(bool on_the_fly)
|
|||||||
if (this == master_unit()->fake_select_lex)
|
if (this == master_unit()->fake_select_lex)
|
||||||
type= "UNION RESULT";
|
type= "UNION RESULT";
|
||||||
|
|
||||||
options|= SELECT_DESCRIBE;
|
if (!on_the_fly)
|
||||||
|
options|= SELECT_DESCRIBE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -262,8 +262,34 @@ void dbug_serve_apcs(THD *thd, int n_calls)
|
|||||||
}
|
}
|
||||||
thd_proc_info(thd, save_proc_info);
|
thd_proc_info(thd, save_proc_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Usage
|
||||||
|
|
||||||
|
DBUG_EXECUTE_IF("show_explain_probe_2",
|
||||||
|
if (dbug_user_var_equals_int(thd, "select_id", select_id))
|
||||||
|
dbug_serve_apcs(thd, 1);
|
||||||
|
);
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool dbug_user_var_equals_int(THD *thd, const char *name, int value)
|
||||||
|
{
|
||||||
|
user_var_entry *var;
|
||||||
|
LEX_STRING varname= {(char*)name, strlen(name)};
|
||||||
|
if ((var= get_variable(&thd->user_vars, varname, FALSE)))
|
||||||
|
{
|
||||||
|
bool null_value;
|
||||||
|
longlong var_value= var->val_int(&null_value);
|
||||||
|
if (!null_value && var_value == value)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This handles SELECT with and without UNION.
|
This handles SELECT with and without UNION.
|
||||||
*/
|
*/
|
||||||
@ -2067,7 +2093,13 @@ void JOIN::exec_inner()
|
|||||||
int tmp_error;
|
int tmp_error;
|
||||||
DBUG_ENTER("JOIN::exec");
|
DBUG_ENTER("JOIN::exec");
|
||||||
|
|
||||||
DBUG_EXECUTE_IF("show_explain_probe_1", dbug_serve_apcs(thd, 1););
|
DBUG_EXECUTE_IF("show_explain_probe_2", dbug_serve_apcs(thd, 1););
|
||||||
|
DBUG_EXECUTE_IF("show_explain_probe_1",
|
||||||
|
if (dbug_user_var_equals_int(thd,
|
||||||
|
"show_explain_probe_select_id",
|
||||||
|
select_lex->select_number))
|
||||||
|
dbug_serve_apcs(thd, 1);
|
||||||
|
);
|
||||||
|
|
||||||
thd_proc_info(thd, "executing");
|
thd_proc_info(thd, "executing");
|
||||||
error= 0;
|
error= 0;
|
||||||
@ -20397,8 +20429,8 @@ void JOIN::clear()
|
|||||||
/**
|
/**
|
||||||
EXPLAIN handling.
|
EXPLAIN handling.
|
||||||
|
|
||||||
Send a description about what how the select will be done to stdout.
|
Produce lines explaining execution of *this* select (not including children
|
||||||
|
selects)
|
||||||
@param on_the_fly TRUE <=> we're being executed on-the-fly, so don't make
|
@param on_the_fly TRUE <=> we're being executed on-the-fly, so don't make
|
||||||
modifications to any select's data structures
|
modifications to any select's data structures
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user