Commit f1f4a195 authored by unknown's avatar unknown

Merge tonu@work.mysql.com:/home/bk/mysql-4.0

into x153.internalnet:/home/tonu/mysql-4.0

parents cc22852e 5b95ffc5
......@@ -56,3 +56,6 @@ t2 c 1
t2 d 1
t2 e 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;
# Test some error conditions with UNION
--error 1215
explain select a,b from t1 union all select a,b from t2;
--error 1215
......
......@@ -6752,23 +6752,25 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
/* Don't log this into the slow query log */
join->thd->lex.select_lex.options&= ~(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED);
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(item=new Item_empty_string("possible_keys",
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("type",10));
field_list.push_back(item=new Item_empty_string("possible_keys",
NAME_LEN*MAX_KEY));
item->maybe_null=1;
field_list.push_back(item=new Item_empty_string("key",NAME_LEN));
item->maybe_null=1;
field_list.push_back(item=new Item_int("key_len",0,3));
item->maybe_null=1;
field_list.push_back(item=new Item_empty_string("ref",
NAME_LEN*MAX_REF_PARTS));
item->maybe_null=1;
field_list.push_back(new Item_real("rows",0.0,0,10));
field_list.push_back(new Item_empty_string("Extra",255));
if (send_fields(thd,field_list,1))
return; /* purecov: inspected */
item->maybe_null=1;
field_list.push_back(item=new Item_empty_string("key",NAME_LEN));
item->maybe_null=1;
field_list.push_back(item=new Item_int("key_len",0,3));
item->maybe_null=1;
field_list.push_back(item=new Item_empty_string("ref",
NAME_LEN*MAX_REF_PARTS));
item->maybe_null=1;
field_list.push_back(new Item_real("rows",0.0,0,10));
field_list.push_back(new Item_empty_string("Extra",255));
if (send_fields(thd,field_list,1))
return;
}
char buff[512],*buff_ptr;
String tmp(buff,sizeof(buff)),*packet= &thd->packet;
table_map used_tables=0;
......@@ -6899,7 +6901,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
// For next iteration
used_tables|=table->map;
}
send_eof(&thd->net);
if (!join->thd->lex.select->next)
send_eof(&thd->net);
DBUG_VOID_RETURN;
}
......
......@@ -38,12 +38,6 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
uint elements;
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 */
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;
{
Item *item;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment