summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <tonu@x153.internalnet>2001-08-26 00:19:17 +0800
committerunknown <tonu@x153.internalnet>2001-08-26 00:19:17 +0800
commitf1f4a195034edaf2bef6c55866f34fdbb42b3ccf (patch)
tree627274ac5b45aa18e4f2bb8062b5a512573e743d
parentcc22852e2e916adca848ae0720131d0963bf8a84 (diff)
parent5b95ffc52ff95e5d47004a592a02eaf834e2c98b (diff)
downloadmariadb-git-f1f4a195034edaf2bef6c55866f34fdbb42b3ccf.tar.gz
Merge tonu@work.mysql.com:/home/bk/mysql-4.0
into x153.internalnet:/home/tonu/mysql-4.0
-rw-r--r--mysql-test/r/union.result3
-rw-r--r--mysql-test/t/union.test1
-rw-r--r--sql/sql_select.cc37
-rw-r--r--sql/sql_union.cc25
4 files changed, 42 insertions, 24 deletions
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 4e87d9880e5..31244341196 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -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
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index d6672185917..c3a0e1ef901 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -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
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 65d2674ba99..1fb6a8d070a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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;
}
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index c2f1dbaa401..a0a6704b631 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -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;