summaryrefslogtreecommitdiff
path: root/sql/sql_derived.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2002-09-26 23:08:22 +0300
committerunknown <bell@sanja.is.com.ua>2002-09-26 23:08:22 +0300
commit9396cc5a4a063f2cccd83721932abb98ce238459 (patch)
tree811744b79667e1e3e450406097ddfc1a03a886db /sql/sql_derived.cc
parent9dea4a4cd1ac246004dc9d223cfc606a7dea5567 (diff)
downloadmariadb-git-9396cc5a4a063f2cccd83721932abb98ce238459.tar.gz
new EXPLAIN
fixed bug in mysql-test/create-test-result fixed bug in union-subselect engine mysql-test/create-test-result: fixed bug in reject file name assembling mysql-test/r/compare.result: new EXPLAIN mysql-test/r/create.result: new EXPLAIN mysql-test/r/distinct.result: new EXPLAIN mysql-test/r/explain.result: new EXPLAIN mysql-test/r/group_by.result: new EXPLAIN mysql-test/r/heap.result: new EXPLAIN mysql-test/r/heap_btree.result: new EXPLAIN mysql-test/r/heap_hash.result: new EXPLAIN mysql-test/r/innodb.result: new EXPLAIN mysql-test/r/join_outer.result: new EXPLAIN mysql-test/r/key_diff.result: new EXPLAIN mysql-test/r/key_primary.result: new EXPLAIN mysql-test/r/merge.result: new EXPLAIN mysql-test/r/myisam.result: new EXPLAIN mysql-test/r/null_key.result: new EXPLAIN mysql-test/r/odbc.result: new EXPLAIN mysql-test/r/order_by.result: new EXPLAIN mysql-test/r/range.result: new EXPLAIN mysql-test/r/select.result: new EXPLAIN mysql-test/r/subselect.result: new EXPLAIN mysql-test/r/type_datetime.result: new EXPLAIN mysql-test/r/union.result: new EXPLAIN mysql-test/r/user_var.result: new EXPLAIN mysql-test/r/varbinary.result: new EXPLAIN mysql-test/t/subselect.test: new EXPLAIN mysql-test/t/union.test: new EXPLAIN sql/mysql_priv.h: new EXPLAIN sql/sql_class.cc: new EXPLAIN sql/sql_class.h: new EXPLAIN sql/sql_derived.cc: new EXPLAIN sql/sql_lex.h: new EXPLAIN sql/sql_parse.cc: new EXPLAIN sql/sql_select.cc: new EXPLAIN sql/sql_union.cc: fixed bug in subselect-UNION engine sql/table.h: new EXPLAIN
Diffstat (limited to 'sql/sql_derived.cc')
-rw-r--r--sql/sql_derived.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index cde120f3774..539a9edb479 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -28,7 +28,8 @@
static const char *any_db="*any*"; // Special symbol for check_access
-int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
+int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t,
+ bool tables_is_opened)
{
/*
TODO: make derived tables with union inside (now only 1 SELECT may be
@@ -37,7 +38,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
SELECT_LEX *sl= unit->first_select();
List<Item> item_list;
TABLE *table;
- int res;
+ int res= 0;
select_union *derived_result;
TABLE_LIST *tables= (TABLE_LIST *)sl->table_list.first;
TMP_TABLE_PARAM tmp_table_param;
@@ -56,7 +57,8 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
{
if (cursor->derived)
{
- res=mysql_derived(thd, lex, (SELECT_LEX_UNIT *)cursor->derived, cursor);
+ res=mysql_derived(thd, lex, (SELECT_LEX_UNIT *)cursor->derived,
+ cursor, 0);
if (res) DBUG_RETURN(res);
}
}
@@ -66,7 +68,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
while ((item= it++))
item_list.push_back(item);
- if (!(res=open_and_lock_tables(thd,tables)))
+ if (tables_is_opened || !(res=open_and_lock_tables(thd,tables)))
{
if (tables && setup_fields(thd,tables,item_list,0,0,1))
{
@@ -94,12 +96,12 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
if (unit->select_limit_cnt == HA_POS_ERROR)
sl->options&= ~OPTION_FOUND_ROWS;
- res=mysql_select(thd, tables, sl->item_list,
- sl->where, (ORDER *) sl->order_list.first,
- (ORDER*) sl->group_list.first,
- sl->having, (ORDER*) NULL,
- sl->options | thd->options | SELECT_NO_UNLOCK,
- derived_result, unit, 0);
+ res= mysql_select(thd, tables, sl->item_list,
+ sl->where, (ORDER *) sl->order_list.first,
+ (ORDER*) sl->group_list.first,
+ sl->having, (ORDER*) NULL,
+ sl->options | thd->options | SELECT_NO_UNLOCK,
+ derived_result, unit, sl, 0);
if (!res)
{
// Here we entirely fix both TABLE_LIST and list of SELECT's as there were no derived tables
@@ -109,6 +111,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
{
t->real_name=table->real_name;
t->table=table;
+ table->derived_select_number= sl->select_number;
sl->exclude();
t->derived=(SELECT_LEX *)0; // just in case ...
}