mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
# MDEV-239: Assertion `field_types == 0 ... ' failed in Protocol_text::store...
- Make all functions that produce parts of EXPLAIN output take explain_flags as parameter, instead of looking into thd->lex->describe
This commit is contained in:
@ -309,4 +309,32 @@ a
|
||||
4
|
||||
set debug='';
|
||||
DROP TABLE t2;
|
||||
#
|
||||
# MDEV-239: Assertion `field_types == 0 ... ' failed in Protocol_text::store(double, uint32, String*) with
|
||||
# SHOW EXPLAIN over EXPLAIN EXTENDED
|
||||
#
|
||||
CREATE TABLE t2 (a INT);
|
||||
INSERT INTO t2 VALUES (1),(2),(1),(4),(2);
|
||||
EXPLAIN EXTENDED SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a ;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 100.00 Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` join `test`.`t2` group by `test`.`t2`.`a`
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug='d,show_explain_probe_join_exec_end';
|
||||
EXPLAIN EXTENDED SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a ;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 EXPLAIN EXTENDED SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 100.00 Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` join `test`.`t2` group by `test`.`t2`.`a`
|
||||
set debug='';
|
||||
DROP TABLE t2;
|
||||
drop table t0,t1;
|
||||
|
@ -319,11 +319,34 @@ evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug='';
|
||||
DROP TABLE t2;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-239: Assertion `field_types == 0 ... ' failed in Protocol_text::store(double, uint32, String*) with
|
||||
--echo # SHOW EXPLAIN over EXPLAIN EXTENDED
|
||||
--echo #
|
||||
|
||||
|
||||
CREATE TABLE t2 (a INT);
|
||||
INSERT INTO t2 VALUES (1),(2),(1),(4),(2);
|
||||
|
||||
EXPLAIN EXTENDED SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a ;
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug='d,show_explain_probe_join_exec_end';
|
||||
send EXPLAIN EXTENDED SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a ;
|
||||
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug='';
|
||||
DROP TABLE t2;
|
||||
|
||||
|
||||
## TODO: Test this: have several SHOW EXPLAIN requests be queued up for a
|
||||
## thread and served together.
|
||||
|
||||
DROP TABLE t2;
|
||||
|
||||
drop table t0,t1;
|
||||
|
@ -3039,7 +3039,7 @@ void Show_explain_request::get_explain_data(void *arg)
|
||||
target_thd->query_length(),
|
||||
&my_charset_bin);
|
||||
|
||||
if (target_thd->lex->unit.print_explain(req->explain_buf))
|
||||
if (target_thd->lex->unit.print_explain(req->explain_buf, 0 /* explain flags */))
|
||||
req->failed_to_produce= TRUE;
|
||||
|
||||
target_thd->restore_active_arena((Query_arena*)req->request_thd,
|
||||
|
@ -3746,12 +3746,13 @@ bool st_select_lex::is_merged_child_of(st_select_lex *ancestor)
|
||||
}
|
||||
|
||||
|
||||
int st_select_lex::print_explain(select_result_sink *output)
|
||||
int st_select_lex::print_explain(select_result_sink *output,
|
||||
uint8 explain_flags)
|
||||
{
|
||||
int res;
|
||||
if (join && join->optimized == 2)
|
||||
{
|
||||
res= join->print_explain(output, TRUE,
|
||||
res= join->print_explain(output, explain_flags, TRUE,
|
||||
join->need_tmp, // need_tmp_table
|
||||
(join->order != 0 && !join->skip_sort_order), // bool need_order
|
||||
join->select_distinct, // bool distinct
|
||||
@ -3769,7 +3770,7 @@ int st_select_lex::print_explain(select_result_sink *output)
|
||||
*/
|
||||
if (!(unit->item && unit->item->eliminated))
|
||||
{
|
||||
unit->print_explain(output);
|
||||
unit->print_explain(output, explain_flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3777,7 +3778,7 @@ int st_select_lex::print_explain(select_result_sink *output)
|
||||
{
|
||||
/* Produce "not yet optimized" line */
|
||||
const char *msg="Not yet optimized";
|
||||
res= join->print_explain(output, TRUE,
|
||||
res= join->print_explain(output, explain_flags, TRUE,
|
||||
FALSE, // need_tmp_table,
|
||||
FALSE, // bool need_order,
|
||||
FALSE, // bool distinct,
|
||||
@ -3788,7 +3789,8 @@ err:
|
||||
}
|
||||
|
||||
|
||||
int st_select_lex_unit::print_explain(select_result_sink *output)
|
||||
int st_select_lex_unit::print_explain(select_result_sink *output,
|
||||
uint8 explain_flags)
|
||||
{
|
||||
int res= 0;
|
||||
SELECT_LEX *first= first_select();
|
||||
@ -3804,7 +3806,7 @@ int st_select_lex_unit::print_explain(select_result_sink *output)
|
||||
|
||||
for (SELECT_LEX *sl= first; sl; sl= sl->next_select())
|
||||
{
|
||||
if ((res= sl->print_explain(output)))
|
||||
if ((res= sl->print_explain(output, explain_flags)))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3814,7 +3816,7 @@ int st_select_lex_unit::print_explain(select_result_sink *output)
|
||||
if (fake_select_lex && !fake_select_lex->join)
|
||||
{
|
||||
res= print_fake_select_lex_join(output, TRUE /* on the fly */,
|
||||
fake_select_lex, 0 /* flags */);
|
||||
fake_select_lex, explain_flags);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -595,7 +595,7 @@ public:
|
||||
friend int subselect_union_engine::exec();
|
||||
|
||||
List<Item> *get_unit_column_types();
|
||||
int print_explain(select_result_sink *output);
|
||||
int print_explain(select_result_sink *output, uint8 explain_flags);
|
||||
};
|
||||
|
||||
typedef class st_select_lex_unit SELECT_LEX_UNIT;
|
||||
@ -918,7 +918,7 @@ public:
|
||||
bool save_prep_leaf_tables(THD *thd);
|
||||
|
||||
bool is_merged_child_of(st_select_lex *ancestor);
|
||||
int print_explain(select_result_sink *output);
|
||||
int print_explain(select_result_sink *output, uint8 explain_flags);
|
||||
/*
|
||||
For MODE_ONLY_FULL_GROUP_BY we need to maintain two flags:
|
||||
- Non-aggregated fields are used in this select.
|
||||
|
@ -2123,6 +2123,14 @@ void JOIN::exec()
|
||||
*/
|
||||
thd->apc_target.enable();
|
||||
exec_inner();
|
||||
|
||||
DBUG_EXECUTE_IF("show_explain_probe_join_exec_end",
|
||||
if (dbug_user_var_equals_int(thd,
|
||||
"show_explain_probe_select_id",
|
||||
select_lex->select_number))
|
||||
dbug_serve_apcs(thd, 1);
|
||||
);
|
||||
|
||||
thd->apc_target.disable();
|
||||
}
|
||||
|
||||
@ -21075,7 +21083,7 @@ void JOIN::clear()
|
||||
|
||||
|
||||
int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
|
||||
SELECT_LEX *select_lex, uint8 select_options)
|
||||
SELECT_LEX *select_lex, uint8 explain_flags)
|
||||
{
|
||||
const CHARSET_INFO *cs= system_charset_info;
|
||||
Item *item_null= new Item_null();
|
||||
@ -21121,7 +21129,7 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
|
||||
item_list.push_back(new Item_string(table_name_buffer, len, cs));
|
||||
}
|
||||
/* partitions */
|
||||
if (/*join->thd->lex->describe*/ select_options & DESCRIBE_PARTITIONS)
|
||||
if (explain_flags & DESCRIBE_PARTITIONS)
|
||||
item_list.push_back(item_null);
|
||||
/* type */
|
||||
item_list.push_back(new Item_string(join_type_str[JT_ALL],
|
||||
@ -21136,7 +21144,7 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
|
||||
/* ref */
|
||||
item_list.push_back(item_null);
|
||||
/* in_rows */
|
||||
if (select_options & DESCRIBE_EXTENDED)
|
||||
if (explain_flags & DESCRIBE_EXTENDED)
|
||||
item_list.push_back(item_null);
|
||||
/* rows */
|
||||
item_list.push_back(item_null);
|
||||
@ -21162,7 +21170,8 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
|
||||
modifications to any select's data structures
|
||||
*/
|
||||
|
||||
int JOIN::print_explain(select_result_sink *result, bool on_the_fly,
|
||||
int JOIN::print_explain(select_result_sink *result, uint8 explain_flags,
|
||||
bool on_the_fly,
|
||||
bool need_tmp_table, bool need_order,
|
||||
bool distinct, const char *message)
|
||||
{
|
||||
@ -21199,9 +21208,9 @@ int JOIN::print_explain(select_result_sink *result, bool on_the_fly,
|
||||
strlen(join->select_lex->type), cs));
|
||||
for (uint i=0 ; i < 7; i++)
|
||||
item_list.push_back(item_null);
|
||||
if (join->thd->lex->describe & DESCRIBE_PARTITIONS)
|
||||
if (explain_flags & DESCRIBE_PARTITIONS)
|
||||
item_list.push_back(item_null);
|
||||
if (join->thd->lex->describe & DESCRIBE_EXTENDED)
|
||||
if (explain_flags & DESCRIBE_EXTENDED)
|
||||
item_list.push_back(item_null);
|
||||
|
||||
item_list.push_back(new Item_string(message,strlen(message),cs));
|
||||
@ -21212,7 +21221,7 @@ int JOIN::print_explain(select_result_sink *result, bool on_the_fly,
|
||||
{
|
||||
if (print_fake_select_lex_join(result, on_the_fly,
|
||||
join->select_lex,
|
||||
join->thd->lex->describe))
|
||||
explain_flags))
|
||||
error= 1;
|
||||
}
|
||||
else if (!join->select_lex->master_unit()->derived ||
|
||||
@ -21317,7 +21326,7 @@ int JOIN::print_explain(select_result_sink *result, bool on_the_fly,
|
||||
cs));
|
||||
}
|
||||
/* "partitions" column */
|
||||
if (join->thd->lex->describe & DESCRIBE_PARTITIONS)
|
||||
if (explain_flags & DESCRIBE_PARTITIONS)
|
||||
{
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
partition_info *part_info;
|
||||
@ -21460,7 +21469,7 @@ int JOIN::print_explain(select_result_sink *result, bool on_the_fly,
|
||||
table_list->schema_table)
|
||||
{
|
||||
/* in_rows */
|
||||
if (join->thd->lex->describe & DESCRIBE_EXTENDED)
|
||||
if (explain_flags & DESCRIBE_EXTENDED)
|
||||
item_list.push_back(item_null);
|
||||
/* rows */
|
||||
item_list.push_back(item_null);
|
||||
@ -21497,7 +21506,7 @@ int JOIN::print_explain(select_result_sink *result, bool on_the_fly,
|
||||
MY_INT64_NUM_DECIMAL_DIGITS));
|
||||
|
||||
/* Add "filtered" field to item_list. */
|
||||
if (join->thd->lex->describe & DESCRIBE_EXTENDED)
|
||||
if (explain_flags & DESCRIBE_EXTENDED)
|
||||
{
|
||||
float f= 0.0;
|
||||
if (examined_rows)
|
||||
@ -21577,7 +21586,7 @@ int JOIN::print_explain(select_result_sink *result, bool on_the_fly,
|
||||
{
|
||||
extra.append(STRING_WITH_LEN("; Using where with pushed "
|
||||
"condition"));
|
||||
if (thd->lex->describe & DESCRIBE_EXTENDED)
|
||||
if (explain_flags & DESCRIBE_EXTENDED)
|
||||
{
|
||||
extra.append(STRING_WITH_LEN(": "));
|
||||
((COND *)pushed_cond)->print(&extra, QT_ORDINARY);
|
||||
@ -21732,7 +21741,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
||||
THD *thd=join->thd;
|
||||
select_result *result=join->result;
|
||||
DBUG_ENTER("select_describe");
|
||||
join->error= join->print_explain(result, FALSE, /* Not on-the-fly */
|
||||
join->error= join->print_explain(result, thd->lex->describe,
|
||||
FALSE, /* Not on-the-fly */
|
||||
need_tmp_table, need_order, distinct,
|
||||
message);
|
||||
|
||||
|
@ -1405,7 +1405,8 @@ public:
|
||||
return (unit->item && unit->item->is_in_predicate());
|
||||
}
|
||||
|
||||
int print_explain(select_result_sink *result, bool on_the_fly,
|
||||
int print_explain(select_result_sink *result, uint8 explain_flags,
|
||||
bool on_the_fly,
|
||||
bool need_tmp_table, bool need_order,
|
||||
bool distinct,const char *message);
|
||||
private:
|
||||
|
Reference in New Issue
Block a user