Commit 62002fdc authored by unknown's avatar unknown

Merge bk-internal:/home/bk/mysql-4.1

into  mysql.com:/home/jimw/my/mysql-4.1-clean

parents ce48949e d68f16e2
...@@ -2617,6 +2617,16 @@ select found_rows(); ...@@ -2617,6 +2617,16 @@ select found_rows();
found_rows() found_rows()
1 1
DROP TABLE t1; 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;
create table t1(f1 int, f2 int); create table t1(f1 int, f2 int);
create table t2(f3 int); create table t2(f3 int);
select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1)); select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1));
......
...@@ -2052,6 +2052,7 @@ AND FK_firma_id = 2; ...@@ -2052,6 +2052,7 @@ AND FK_firma_id = 2;
drop table t1; drop table t1;
#
# #
# Test for Bug#8009, SELECT failed on bigint unsigned when using HEX # Test for Bug#8009, SELECT failed on bigint unsigned when using HEX
# #
...@@ -2164,6 +2165,16 @@ select found_rows(); ...@@ -2164,6 +2165,16 @@ select found_rows();
DROP TABLE t1; 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;
# #
# Bug #13356 assertion failed in resolve_const_item() # Bug #13356 assertion failed in resolve_const_item()
# #
......
...@@ -1760,6 +1760,21 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -1760,6 +1760,21 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if ((tmp= find_field_in_tables(thd, this, tables, &where, 0)) == if ((tmp= find_field_in_tables(thd, this, tables, &where, 0)) ==
not_found_field) not_found_field)
{ {
/* Look up in current select's item_list to find aliased fields */
if (thd->lex->current_select->is_item_list_lookup)
{
uint counter;
bool not_used;
Item** res= find_item_in_list(this, thd->lex->current_select->item_list,
&counter, REPORT_EXCEPT_NOT_FOUND,
&not_used);
if (res != not_found_item && (*res)->type() == Item::FIELD_ITEM)
{
set_field((*((Item_field**)res))->field);
return 0;
}
}
/* /*
We can't find table field in table list of current select, We can't find table field in table list of current select,
consequently we have to find it in outer subselect(s). consequently we have to find it in outer subselect(s).
......
...@@ -1083,6 +1083,7 @@ void st_select_lex::init_query() ...@@ -1083,6 +1083,7 @@ void st_select_lex::init_query()
prep_where= 0; prep_where= 0;
subquery_in_having= explicit_limit= 0; subquery_in_having= explicit_limit= 0;
parsing_place= NO_MATTER; parsing_place= NO_MATTER;
is_item_list_lookup= 0;
} }
void st_select_lex::init_select() void st_select_lex::init_select()
...@@ -1109,6 +1110,7 @@ void st_select_lex::init_select() ...@@ -1109,6 +1110,7 @@ void st_select_lex::init_select()
select_limit= HA_POS_ERROR; select_limit= HA_POS_ERROR;
offset_limit= 0; offset_limit= 0;
with_sum_func= 0; with_sum_func= 0;
} }
/* /*
......
...@@ -426,6 +426,7 @@ public: ...@@ -426,6 +426,7 @@ public:
List<Item> item_list; /* list of fields & expressions */ List<Item> item_list; /* list of fields & expressions */
List<String> interval_list, use_index, *use_index_ptr, List<String> interval_list, use_index, *use_index_ptr,
ignore_index, *ignore_index_ptr; ignore_index, *ignore_index_ptr;
bool is_item_list_lookup;
/* /*
Usualy it is pointer to ftfunc_list_alloc, but in union used to create fake Usualy it is pointer to ftfunc_list_alloc, but in union used to create fake
select_lex for calling mysql_select under results of union select_lex for calling mysql_select under results of union
......
...@@ -8348,11 +8348,16 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, ...@@ -8348,11 +8348,16 @@ find_order_in_list(THD *thd, Item **ref_pointer_array,
'it' reassigned in if condition because fix_field can change it. 'it' reassigned in if condition because fix_field can change it.
*/ */
thd->lex->current_select->is_item_list_lookup= 1;
if (!it->fixed && if (!it->fixed &&
(it->fix_fields(thd, tables, order->item) || (it->fix_fields(thd, tables, order->item) ||
(it= *order->item)->check_cols(1) || (it= *order->item)->check_cols(1) ||
thd->is_fatal_error)) thd->is_fatal_error))
{
thd->lex->current_select->is_item_list_lookup= 0;
return 1; // Wrong field return 1; // Wrong field
}
thd->lex->current_select->is_item_list_lookup= 0;
uint el= all_fields.elements; uint el= all_fields.elements;
all_fields.push_front(it); // Add new field to field list all_fields.push_front(it); // Add new field to field list
ref_pointer_array[el]= it; ref_pointer_array[el]= it;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment