EXPLAIN on UNION"s
This commit is contained in:
parent
66b4a894dd
commit
3b6546b875
@ -56,3 +56,6 @@ t2 c 1
|
|||||||
t2 d 1
|
t2 d 1
|
||||||
t2 e 1
|
t2 e 1
|
||||||
t2 f 1
|
t2 f 1
|
||||||
|
table type possible_keys key key_len ref rows Extra
|
||||||
|
t1 ALL NULL NULL NULL NULL 4
|
||||||
|
t2 ALL NULL NULL NULL NULL 4
|
||||||
|
@ -17,7 +17,6 @@ select a,b from t1 union select a,b from t1;
|
|||||||
select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 group by b;
|
select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 group by b;
|
||||||
|
|
||||||
# Test some error conditions with UNION
|
# Test some error conditions with UNION
|
||||||
--error 1215
|
|
||||||
explain select a,b from t1 union all select a,b from t2;
|
explain select a,b from t1 union all select a,b from t2;
|
||||||
|
|
||||||
--error 1215
|
--error 1215
|
||||||
|
@ -6752,6 +6752,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||||||
|
|
||||||
/* Don't log this into the slow query log */
|
/* Don't log this into the slow query log */
|
||||||
join->thd->lex.select_lex.options&= ~(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED);
|
join->thd->lex.select_lex.options&= ~(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED);
|
||||||
|
if (join->thd->lex.select == &join->thd->lex.select_lex)
|
||||||
|
{
|
||||||
field_list.push_back(new Item_empty_string("table",NAME_LEN));
|
field_list.push_back(new Item_empty_string("table",NAME_LEN));
|
||||||
field_list.push_back(new Item_empty_string("type",10));
|
field_list.push_back(new Item_empty_string("type",10));
|
||||||
field_list.push_back(item=new Item_empty_string("possible_keys",
|
field_list.push_back(item=new Item_empty_string("possible_keys",
|
||||||
@ -6767,8 +6769,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||||||
field_list.push_back(new Item_real("rows",0.0,0,10));
|
field_list.push_back(new Item_real("rows",0.0,0,10));
|
||||||
field_list.push_back(new Item_empty_string("Extra",255));
|
field_list.push_back(new Item_empty_string("Extra",255));
|
||||||
if (send_fields(thd,field_list,1))
|
if (send_fields(thd,field_list,1))
|
||||||
return; /* purecov: inspected */
|
return;
|
||||||
|
}
|
||||||
char buff[512],*buff_ptr;
|
char buff[512],*buff_ptr;
|
||||||
String tmp(buff,sizeof(buff)),*packet= &thd->packet;
|
String tmp(buff,sizeof(buff)),*packet= &thd->packet;
|
||||||
table_map used_tables=0;
|
table_map used_tables=0;
|
||||||
@ -6899,6 +6901,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||||||
// For next iteration
|
// For next iteration
|
||||||
used_tables|=table->map;
|
used_tables|=table->map;
|
||||||
}
|
}
|
||||||
|
if (!join->thd->lex.select->next)
|
||||||
send_eof(&thd->net);
|
send_eof(&thd->net);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,6 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
|
|||||||
uint elements;
|
uint elements;
|
||||||
DBUG_ENTER("mysql_union");
|
DBUG_ENTER("mysql_union");
|
||||||
|
|
||||||
if (lex->select_lex.options & SELECT_DESCRIBE)
|
|
||||||
{
|
|
||||||
my_error(ER_WRONG_USAGE,MYF(0),"DESCRIBE","UNION");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fix tables--to-be-unioned-from list to point at opened tables */
|
/* Fix tables--to-be-unioned-from list to point at opened tables */
|
||||||
for (sl=&lex->select_lex; sl; sl=sl->next)
|
for (sl=&lex->select_lex; sl; sl=sl->next)
|
||||||
{
|
{
|
||||||
@ -66,6 +60,25 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lex->select_lex.options & SELECT_DESCRIBE)
|
||||||
|
{
|
||||||
|
for (sl= &lex->select_lex; sl; sl=sl->next)
|
||||||
|
{
|
||||||
|
lex->select=sl;
|
||||||
|
res=mysql_select(thd, (TABLE_LIST*) sl->table_list.first,
|
||||||
|
sl->item_list,
|
||||||
|
sl->where,
|
||||||
|
sl->ftfunc_list,
|
||||||
|
(ORDER*) 0,
|
||||||
|
(ORDER*) sl->group_list.first,
|
||||||
|
sl->having,
|
||||||
|
(ORDER*) NULL,
|
||||||
|
sl->options | thd->options | SELECT_NO_UNLOCK | SELECT_DESCRIBE,
|
||||||
|
result);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
order = (ORDER *) last_sl->order_list.first;
|
order = (ORDER *) last_sl->order_list.first;
|
||||||
{
|
{
|
||||||
Item *item;
|
Item *item;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user