Commit 785b7dbc authored by unknown's avatar unknown
Browse files

Manual merge of bug fix #7672


sql/sql_lex.h:
  Auto merged
parents af43bd9d d68f16e2
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2737,6 +2737,16 @@ id select_type table type possible_keys key key_len ref rows Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	5	
1	SIMPLE	t2	ref	a	a	23	test.t1.a	2	
DROP TABLE t1, t2;
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 (a int, b int);
create table t2 like t1;
select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1;
+11 −0
Original line number Diff line number Diff line
@@ -2069,6 +2069,7 @@ AND FK_firma_id = 2;

drop table t1;

#
#
# Test for Bug#8009, SELECT failed on bigint unsigned when using HEX
#
@@ -2181,6 +2182,16 @@ select found_rows();

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()
#
+16 −0
Original line number Diff line number Diff line
@@ -3213,6 +3213,22 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
                                          TRUE)) ==
	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;
        }
      }

      /*
        If there are outer contexts (outer selects, but current select is
        not derived table or view) try to resolve this reference in the
+2 −0
Original line number Diff line number Diff line
@@ -1133,6 +1133,7 @@ void st_select_lex::init_query()
  ref_pointer_array= 0;
  select_n_having_items= 0;
  subquery_in_having= explicit_limit= 0;
  is_item_list_lookup= 0;
  first_execution= 1;
  first_cond_optimization= 1;
  parsing_place= NO_MATTER;
@@ -1165,6 +1166,7 @@ void st_select_lex::init_select()
  select_limit= 0;      /* denotes the default limit = HA_POS_ERROR */
  offset_limit= 0;      /* denotes the default offset = 0 */
  with_sum_func= 0;

}

/*
+1 −0
Original line number Diff line number Diff line
@@ -482,6 +482,7 @@ class st_select_lex: public st_select_lex_node
  List<Item>          item_list;  /* list of fields & expressions */
  List<String>        interval_list, use_index, *use_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
    select_lex for calling mysql_select under results of union
Loading