Commit 77ee831d authored by unknown's avatar unknown
Browse files

fixed temporary table processing expresions of subqueries and removed wrong...

fixed temporary table processing expresions of subqueries and removed wrong restrictions of field resolving (BUG#5326)


mysql-test/r/subselect.result:
  tests of fields resolving
mysql-test/t/subselect.test:
  tests of fields resolving
sql/item.cc:
  fixed fild resolving
sql/item_subselect.cc:
  removed aneed call
sql/sql_base.cc:
  fixed case whan we scan un-fixfielded fields
sql/sql_select.cc:
  fixed temporary table processing expresions of subqueries
parent 1230daf8
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1966,5 +1966,13 @@ howmanyvalues mycount
3	3
4	4
SELECT a.howmanyvalues, (SELECT count(*) from t1 b where b.howmanyvalues = a.avalue) as mycount from t1 a group by a.howmanyvalues;
ERROR 42S22: Unknown column 'a.avalue' in 'where clause'
howmanyvalues	mycount
1	1
2	1
3	1
4	1
drop table t1;
create table t1 (x int);
select  (select b.x from t1 as b where b.x=a.x) from t1 as a where a.x=2 group by a.x;
(select b.x from t1 as b where b.x=a.x)
drop table t1;
+4 −1
Original line number Diff line number Diff line
@@ -1264,6 +1264,9 @@ SELECT a.howmanyvalues, (SELECT count(*) from t1 b where b.howmanyvalues = a.how
CREATE INDEX t1_howmanyvalues_idx ON t1 (howmanyvalues);
SELECT a.howmanyvalues, (SELECT count(*) from t1 b where b.howmanyvalues+1 = a.howmanyvalues+1) as mycount from t1 a group by a.howmanyvalues;
SELECT a.howmanyvalues, (SELECT count(*) from t1 b where b.howmanyvalues = a.howmanyvalues) as mycount from t1 a group by a.howmanyvalues;
-- error 1054
SELECT a.howmanyvalues, (SELECT count(*) from t1 b where b.howmanyvalues = a.avalue) as mycount from t1 a group by a.howmanyvalues;
drop table t1;

create table t1 (x int);
select  (select b.x from t1 as b where b.x=a.x) from t1 as a where a.x=2 group by a.x;
drop table t1;
+4 −6
Original line number Diff line number Diff line
@@ -1271,11 +1271,10 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
            prev_subselect_item->parsing_place;
          /*
            check table fields only if subquery used somewhere out of HAVING
            or SELECT list or outer SELECT do not use groupping (i.e. tables
            are accessable)
            or outer SELECT do not use groupping (i.e. tables are
            accessable)
          */
          if (((place != IN_HAVING &&
                place != SELECT_LIST) ||
          if ((place != IN_HAVING ||
               (sl->with_sum_func == 0 && sl->group_list.elements == 0)) &&
              (tmp= find_field_in_tables(thd, this,
                                         table_list, &where,
@@ -1952,8 +1951,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
          or SELECT list or outer SELECT do not use groupping (i.e. tables
          are accessable)
        */
        if (((place != IN_HAVING &&
              place != SELECT_LIST) ||
        if ((place != IN_HAVING ||
             (sl->with_sum_func == 0 && sl->group_list.elements == 0)) &&
            (tmp= find_field_in_tables(thd, this,
                                       table_list, &where,
+0 −3
Original line number Diff line number Diff line
@@ -934,9 +934,6 @@ Item_in_subselect::row_value_transformer(JOIN *join)
  }

  select_lex->uncacheable|= UNCACHEABLE_DEPENDENT;
  select_lex->setup_ref_array(thd,
			      select_lex->order_list.elements +
			      select_lex->group_list.elements);
  {
    uint n= left_expr->cols();
    List_iterator_fast<Item> li(select_lex->item_list);
+5 −1
Original line number Diff line number Diff line
@@ -2142,8 +2142,12 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
          case sensitive.
          In cases where they are not case sensitive, they are always in lower
          case.

	  item_field->field_name and item_field->table_name can be 0x0 if
	  item is not fix fielded yet.
        */
        if (!my_strcasecmp(system_charset_info, item_field->field_name,
        if (item_field->field_name && item_field->table_name &&
	    !my_strcasecmp(system_charset_info, item_field->field_name,
                           field_name) &&
            !strcmp(item_field->table_name, table_name) &&
            (!db_name || (item_field->db_name &&
Loading