From: Date: October 12 2005 10:59pm Subject: bk commit into 4.1 tree (evgen:1.2458) BUG#7672 List-Archive: http://lists.mysql.com/internals/30987 X-Bug: 7672 Message-Id: <20051012205902.A4FBD13E82E@localhost.moonbone.local> Below is the list of changes that have just been committed into a local 4.1 repository of evgen. When evgen does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2458 05/10/13 00:58:59 evgen@stripped +4 -0 select.test, sql_select.cc, sql_lex.cc, item.cc: Bug #7672 after merge fix mysql-test/t/select.test 1.48 05/10/13 00:52:58 evgen@stripped +2 -1 Bug #7672 after merge fix sql/sql_select.cc 1.439 05/10/13 00:51:48 evgen@stripped +5 -0 Bug #7672 after merge fix sql/sql_lex.cc 1.151 05/10/13 00:51:38 evgen@stripped +2 -1 Bug #7672 after merge fix sql/item.cc 1.223 05/10/13 00:51:02 evgen@stripped +8 -3 Bug #7672 after merge fix # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: evgen # Host: moonbone.local # Root: /work/7672-bug-4.1-mysql --- 1.222/sql/item.cc 2005-10-12 03:32:13 +04:00 +++ 1.223/sql/item.cc 2005-10-13 00:51:02 +04:00 @@ -1760,10 +1760,15 @@ if ((tmp= find_field_in_tables(thd, this, tables, &where, 0)) == not_found_field) { - if (thd->lex.select_lex.is_item_list_lookup) + /* Look up in current select's item_list to find aliased fields */ + if (thd->lex->current_select->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) + uint counter; + bool not_used; + Item** res= find_item_in_list(this, thd->lex->current_select->item_list, + &counter, REPORT_EXCEPT_NOT_FOUND, + ¬_used); + if (res != not_found_item && (*res)->type() == Item::FIELD_ITEM) { set_field((*((Item_field**)res))->field); return 0; --- 1.150/sql/sql_lex.cc 2005-10-12 03:32:13 +04:00 +++ 1.151/sql/sql_lex.cc 2005-10-13 00:51:38 +04:00 @@ -160,7 +160,6 @@ lex->duplicates= DUP_ERROR; lex->ignore= 0; lex->proc_list.first= 0; - lex->select_lex.is_item_list_lookup= 0; } void lex_end(LEX *lex) @@ -1084,6 +1083,7 @@ prep_where= 0; subquery_in_having= explicit_limit= 0; parsing_place= NO_MATTER; + is_item_list_lookup= 0; } void st_select_lex::init_select() @@ -1110,6 +1110,7 @@ select_limit= HA_POS_ERROR; offset_limit= 0; with_sum_func= 0; + } /* --- 1.438/sql/sql_select.cc 2005-10-12 03:32:13 +04:00 +++ 1.439/sql/sql_select.cc 2005-10-13 00:51:48 +04:00 @@ -8348,11 +8348,16 @@ 'it' reassigned in if condition because fix_field can change it. */ + thd->lex->current_select->is_item_list_lookup= 1; if (!it->fixed && (it->fix_fields(thd, tables, order->item) || (it= *order->item)->check_cols(1) || thd->is_fatal_error)) + { + thd->lex->current_select->is_item_list_lookup= 0; return 1; // Wrong field + } + thd->lex->current_select->is_item_list_lookup= 0; uint el= all_fields.elements; all_fields.push_front(it); // Add new field to field list ref_pointer_array[el]= it; --- 1.47/mysql-test/t/select.test 2005-10-12 03:32:13 +04:00 +++ 1.48/mysql-test/t/select.test 2005-10-13 00:52:58 +04:00 @@ -2165,7 +2165,7 @@ DROP TABLE t1; -# End of 4.1 tests +# # Bug 7672 Unknown column error in order clause # CREATE TABLE t1 (a INT, b INT); @@ -2174,3 +2174,4 @@ 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; +# End of 4.1 tests