diff options
author | unknown <bell@sanja.is.com.ua> | 2003-05-21 23:35:51 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-05-21 23:35:51 +0300 |
commit | 26aeebfaf7fd0cc08e02724c6c12c849e25ed151 (patch) | |
tree | 198e36335229ed9cd4573d38704aac96873c0ab0 /sql/item.cc | |
parent | 4637832fa19b2866929c1e5cb7c9dd0a40db15c9 (diff) | |
download | mariadb-git-26aeebfaf7fd0cc08e02724c6c12c849e25ed151.tar.gz |
fixed subqueries name resolution with INSERT/REPLACE (found during bug 446 investigation)
mysql-test/r/subselect.result:
subselect test changed
mysql-test/t/subselect.test:
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2));
sql/item.cc:
avoid resolving of INSER/REPLACE tables field in subqueries
sql/sql_lex.cc:
Primary (top) simple INSERT/REPLACE st_select_lex indicator
sql/sql_lex.h:
Primary (top) simple INSERT/REPLACE st_select_lex indicator
sql/sql_yacc.yy:
Primary (top) simple INSERT/REPLACE st_select_lex indicator
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sql/item.cc b/sql/item.cc index 053a94cb695..871031f1571 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -758,6 +758,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) #ifdef EMBEDDED_LIBRARY thd->net.last_errno= 0; #endif + TABLE_LIST *table_list; Item **refer= (Item **)not_found_item; uint counter; // Prevent using outer fields in subselects, that is not supported now @@ -768,8 +769,14 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) sl; sl= sl->outer_select()) { + table_list= (last= sl)->get_table_list(); + if (sl->insert_select && table_list) + { + // it is primary INSERT st_select_lex => skip first table resolving + table_list= table_list->next; + } if ((tmp= find_field_in_tables(thd, this, - (last= sl)->get_table_list(), &where, + table_list, &where, 0)) != not_found_field) break; if ((refer= find_item_in_list(this, sl->item_list, &counter, @@ -1221,7 +1228,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) uint counter; if (!ref) { - TABLE_LIST *where= 0; + TABLE_LIST *where= 0, *table_list; SELECT_LEX *sl= (outer_resolving? thd->lex.current_select->select_lex(): thd->lex.current_select->outer_select()); @@ -1260,8 +1267,14 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) REPORT_EXCEPT_NOT_FOUND)) != (Item **)not_found_item) break; + table_list= sl->get_table_list(); + if (sl->insert_select && table_list) + { + // it is primary INSERT st_select_lex => skip first table resolving + table_list= table_list->next; + } if ((tmp= find_field_in_tables(thd, this, - sl->get_table_list(), &where, + table_list, &where, 0)) != not_found_field) break; if (sl->master_unit()->first_select()->linkage == |