Loading mysql-test/r/select.result +10 −0 Original line number Diff line number Diff line Loading @@ -2431,3 +2431,13 @@ AND FK_firma_id = 2; COUNT(*) 0 drop table t1; CREATE TABLE t1 (a INT, b INT); (SELECT a, b AS c FROM t1) ORDER BY c+1; a c (SELECT a, b AS c FROM t1) ORDER BY b+1; a c SELECT a, b AS c FROM t1 ORDER BY c+1; a c SELECT a, b AS c FROM t1 ORDER BY b+1; a c drop table t1; mysql-test/t/select.test +9 −0 Original line number Diff line number Diff line Loading @@ -1983,3 +1983,12 @@ AND FK_firma_id = 2; drop table t1; # # Bug 7672 Unknown column error in order clause # CREATE TABLE t1 (a INT, b INT); (SELECT a, b AS c FROM t1) ORDER BY c+1; (SELECT a, b AS c FROM t1) ORDER BY b+1; SELECT a, b AS c FROM t1 ORDER BY c+1; SELECT a, b AS c FROM t1 ORDER BY b+1; drop table t1; sql/item.cc +11 −0 Original line number Diff line number Diff line Loading @@ -348,7 +348,18 @@ bool Item_field::fix_fields(THD *thd,TABLE_LIST *tables) { Field *tmp; if (!(tmp=find_field_in_tables(thd,this,tables))) { if (thd->lex.select_lex.is_item_list_lookup) { Item** res= find_item_in_list(this, thd->lex.select_lex.item_list); if (res && *res && (*res)->type() == Item::FIELD_ITEM) { set_field((*((Item_field**)res))->field); return 0; } } return 1; } set_field(tmp); } else if (thd && thd->set_query_id && field->query_id != thd->query_id) Loading sql/sql_lex.cc +1 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length) lex->slave_thd_opt=0; lex->sql_command=SQLCOM_END; bzero((char *)&lex->mi,sizeof(lex->mi)); lex->select_lex.is_item_list_lookup= 0; return lex; } Loading sql/sql_lex.h +1 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ typedef struct st_select_lex ignore_index, *ignore_index_ptr; List<Item_func_match> ftfunc_list; uint in_sum_expr, sort_default; bool create_refs, braces; bool create_refs, braces, is_item_list_lookup; st_select_lex *next; } SELECT_LEX; Loading Loading
mysql-test/r/select.result +10 −0 Original line number Diff line number Diff line Loading @@ -2431,3 +2431,13 @@ AND FK_firma_id = 2; COUNT(*) 0 drop table t1; CREATE TABLE t1 (a INT, b INT); (SELECT a, b AS c FROM t1) ORDER BY c+1; a c (SELECT a, b AS c FROM t1) ORDER BY b+1; a c SELECT a, b AS c FROM t1 ORDER BY c+1; a c SELECT a, b AS c FROM t1 ORDER BY b+1; a c drop table t1;
mysql-test/t/select.test +9 −0 Original line number Diff line number Diff line Loading @@ -1983,3 +1983,12 @@ AND FK_firma_id = 2; drop table t1; # # Bug 7672 Unknown column error in order clause # CREATE TABLE t1 (a INT, b INT); (SELECT a, b AS c FROM t1) ORDER BY c+1; (SELECT a, b AS c FROM t1) ORDER BY b+1; SELECT a, b AS c FROM t1 ORDER BY c+1; SELECT a, b AS c FROM t1 ORDER BY b+1; drop table t1;
sql/item.cc +11 −0 Original line number Diff line number Diff line Loading @@ -348,7 +348,18 @@ bool Item_field::fix_fields(THD *thd,TABLE_LIST *tables) { Field *tmp; if (!(tmp=find_field_in_tables(thd,this,tables))) { if (thd->lex.select_lex.is_item_list_lookup) { Item** res= find_item_in_list(this, thd->lex.select_lex.item_list); if (res && *res && (*res)->type() == Item::FIELD_ITEM) { set_field((*((Item_field**)res))->field); return 0; } } return 1; } set_field(tmp); } else if (thd && thd->set_query_id && field->query_id != thd->query_id) Loading
sql/sql_lex.cc +1 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length) lex->slave_thd_opt=0; lex->sql_command=SQLCOM_END; bzero((char *)&lex->mi,sizeof(lex->mi)); lex->select_lex.is_item_list_lookup= 0; return lex; } Loading
sql/sql_lex.h +1 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ typedef struct st_select_lex ignore_index, *ignore_index_ptr; List<Item_func_match> ftfunc_list; uint in_sum_expr, sort_default; bool create_refs, braces; bool create_refs, braces, is_item_list_lookup; st_select_lex *next; } SELECT_LEX; Loading