diff options
author | dlenev@brandersnatch.localdomain <> | 2004-09-30 16:28:17 +0400 |
---|---|---|
committer | dlenev@brandersnatch.localdomain <> | 2004-09-30 16:28:17 +0400 |
commit | 0aa589d0998b41f3e0f55e1f62e86ec8d9d17ba9 (patch) | |
tree | 869403a16f8b3c117fed13dae2bac7e2f7ab89b6 /sql/item.cc | |
parent | 36548b10ca2d796c46436ab445569f6e0476ecaf (diff) | |
download | mariadb-git-0aa589d0998b41f3e0f55e1f62e86ec8d9d17ba9.tar.gz |
Final solution for bug# 4302 "Ambiguos order by when renamed column is
identical to another in result"
According to SQL standard queries like
"select t1.a as col from t1, t2 order by a" should return an error if
both tables contain field a.
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sql/item.cc b/sql/item.cc index 14136435a50..3c9b54074dc 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1246,6 +1246,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) TABLE_LIST *table_list; Item **refer= (Item **)not_found_item; uint counter; + bool not_used; // Prevent using outer fields in subselects, that is not supported now SELECT_LEX *cursel= (SELECT_LEX *) thd->lex->current_select; if (cursel->master_unit()->first_select()->linkage != DERIVED_TABLE_TYPE) @@ -1288,7 +1289,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) } if (sl->resolve_mode == SELECT_LEX::SELECT_MODE && (refer= find_item_in_list(this, sl->item_list, &counter, - REPORT_EXCEPT_NOT_FOUND)) != + REPORT_EXCEPT_NOT_FOUND, + ¬_used)) != (Item **) not_found_item) { if (*refer && (*refer)->fixed) // Avoid crash in case of error @@ -1889,6 +1891,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) { DBUG_ASSERT(fixed == 0); uint counter; + bool not_used; if (!ref) { TABLE_LIST *where= 0, *table_list; @@ -1908,13 +1911,13 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) first_select()->linkage != DERIVED_TABLE_TYPE) ? REPORT_EXCEPT_NOT_FOUND : - REPORT_ALL_ERRORS))) == + REPORT_ALL_ERRORS ), ¬_used)) == (Item **)not_found_item) { upward_lookup= 1; Field *tmp= (Field*) not_found_field; /* - We can't find table field in table list of current select, + We can't find table field in select list of current select, consequently we have to find it in outer subselect(s). We can't join lists of outer & current select, because of scope of view rules. For example if both tables (outer & current) have @@ -1929,8 +1932,8 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) Item_subselect *prev_subselect_item= prev_unit->item; if (sl->resolve_mode == SELECT_LEX::SELECT_MODE && (ref= find_item_in_list(this, sl->item_list, - &counter, - REPORT_EXCEPT_NOT_FOUND)) != + &counter, REPORT_EXCEPT_NOT_FOUND, + ¬_used)) != (Item **)not_found_item) { if (*ref && (*ref)->fixed) // Avoid crash in case of error @@ -1989,8 +1992,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) // Call to report error find_item_in_list(this, *(thd->lex->current_select->get_item_list()), - &counter, - REPORT_ALL_ERRORS); + &counter, REPORT_ALL_ERRORS, ¬_used); } ref= 0; return 1; |