Commit 35b15c8d authored by unknown's avatar unknown

Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.1-opt

into  magare.gmz:/home/kgeorge/mysql/autopush/B27786-addon-5.1-opt


mysql-test/r/subselect3.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/t/view.test:
  Auto merged
sql/item_subselect.cc:
  Auto merged
sql/item_subselect.h:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
parents cf0dd73c ae5865ff
...@@ -82,7 +82,7 @@ void Item_subselect::init(st_select_lex *select_lex, ...@@ -82,7 +82,7 @@ void Item_subselect::init(st_select_lex *select_lex,
parsing_place= (outer_select->in_sum_expr ? parsing_place= (outer_select->in_sum_expr ?
NO_MATTER : NO_MATTER :
outer_select->parsing_place); outer_select->parsing_place);
if (select_lex->next_select()) if (unit->is_union())
engine= new subselect_union_engine(unit, result, this); engine= new subselect_union_engine(unit, result, this);
else else
engine= new subselect_single_select_engine(select_lex, result, this); engine= new subselect_single_select_engine(select_lex, result, this);
...@@ -412,7 +412,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join) ...@@ -412,7 +412,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
SELECT_LEX *select_lex= join->select_lex; SELECT_LEX *select_lex= join->select_lex;
Query_arena *arena= thd->stmt_arena; Query_arena *arena= thd->stmt_arena;
if (!select_lex->master_unit()->first_select()->next_select() && if (!select_lex->master_unit()->is_union() &&
!select_lex->table_list.elements && !select_lex->table_list.elements &&
select_lex->item_list.elements == 1 && select_lex->item_list.elements == 1 &&
!select_lex->item_list.head()->with_sum_func && !select_lex->item_list.head()->with_sum_func &&
...@@ -1147,7 +1147,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, ...@@ -1147,7 +1147,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
else else
{ {
bool tmp; bool tmp;
if (select_lex->master_unit()->first_select()->next_select()) if (select_lex->master_unit()->is_union())
{ {
/* /*
comparison functions can't be changed during fix_fields() comparison functions can't be changed during fix_fields()
......
...@@ -236,9 +236,7 @@ bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *orig_table_list) ...@@ -236,9 +236,7 @@ bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
SELECT_LEX *first_select= unit->first_select(); SELECT_LEX *first_select= unit->first_select();
select_union *derived_result= orig_table_list->derived_result; select_union *derived_result= orig_table_list->derived_result;
SELECT_LEX *save_current_select= lex->current_select; SELECT_LEX *save_current_select= lex->current_select;
bool is_union= first_select->next_select() && if (unit->is_union())
first_select->next_select()->linkage == UNION_TYPE;
if (is_union)
{ {
// execute union without clean up // execute union without clean up
res= unit->exec(); res= unit->exec();
......
...@@ -796,7 +796,6 @@ private: ...@@ -796,7 +796,6 @@ private:
}; };
typedef class st_select_lex SELECT_LEX; typedef class st_select_lex SELECT_LEX;
inline bool st_select_lex_unit::is_union () inline bool st_select_lex_unit::is_union ()
{ {
return first_select()->next_select() && return first_select()->next_select() &&
......
...@@ -5961,7 +5961,7 @@ bool st_select_lex_unit::add_fake_select_lex(THD *thd_arg) ...@@ -5961,7 +5961,7 @@ bool st_select_lex_unit::add_fake_select_lex(THD *thd_arg)
fake_select_lex->context.resolve_in_select_list= TRUE; fake_select_lex->context.resolve_in_select_list= TRUE;
fake_select_lex->context.select_lex= fake_select_lex; fake_select_lex->context.select_lex= fake_select_lex;
if (!first_sl->next_select()) if (!is_union())
{ {
/* /*
This works only for This works only for
......
...@@ -231,7 +231,8 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, ...@@ -231,7 +231,8 @@ bool handle_select(THD *thd, LEX *lex, select_result *result,
register SELECT_LEX *select_lex = &lex->select_lex; register SELECT_LEX *select_lex = &lex->select_lex;
DBUG_ENTER("handle_select"); DBUG_ENTER("handle_select");
if (select_lex->next_select() || select_lex->master_unit()->fake_select_lex) if (select_lex->master_unit()->is_union() ||
select_lex->master_unit()->fake_select_lex)
res= mysql_union(thd, lex, result, &lex->unit, setup_tables_done_option); res= mysql_union(thd, lex, result, &lex->unit, setup_tables_done_option);
else else
{ {
...@@ -442,7 +443,7 @@ JOIN::prepare(Item ***rref_pointer_array, ...@@ -442,7 +443,7 @@ JOIN::prepare(Item ***rref_pointer_array,
select_lex= select_lex_arg; select_lex= select_lex_arg;
select_lex->join= this; select_lex->join= this;
join_list= &select_lex->top_join_list; join_list= &select_lex->top_join_list;
union_part= (unit_arg->first_select()->next_select() != 0); union_part= unit_arg->is_union();
thd->lex->current_select->is_item_list_lookup= 1; thd->lex->current_select->is_item_list_lookup= 1;
/* /*
...@@ -1191,7 +1192,7 @@ JOIN::optimize() ...@@ -1191,7 +1192,7 @@ JOIN::optimize()
if (!group_list && !order && if (!group_list && !order &&
unit->item && unit->item->substype() == Item_subselect::IN_SUBS && unit->item && unit->item->substype() == Item_subselect::IN_SUBS &&
tables == 1 && conds && tables == 1 && conds &&
!unit->first_select()->next_select()) !unit->is_union())
{ {
if (!having) if (!having)
{ {
...@@ -3165,7 +3166,7 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level, ...@@ -3165,7 +3166,7 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
if (!join->group_list && !join->order && if (!join->group_list && !join->order &&
join->unit->item && join->unit->item &&
join->unit->item->substype() == Item_subselect::IN_SUBS && join->unit->item->substype() == Item_subselect::IN_SUBS &&
!join->unit->first_select()->next_select()) !join->unit->is_union())
{ {
KEY_FIELD *save= *key_fields; KEY_FIELD *save= *key_fields;
add_key_fields(join, key_fields, and_level, cond_arg, usable_tables, add_key_fields(join, key_fields, and_level, cond_arg, usable_tables,
...@@ -15523,7 +15524,7 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) ...@@ -15523,7 +15524,7 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
"UNION"))); "UNION")));
sl->options|= SELECT_DESCRIBE; sl->options|= SELECT_DESCRIBE;
} }
if (first->next_select()) if (unit->is_union())
{ {
unit->fake_select_lex->select_number= UINT_MAX; // jost for initialization unit->fake_select_lex->select_number= UINT_MAX; // jost for initialization
unit->fake_select_lex->type= "UNION RESULT"; unit->fake_select_lex->type= "UNION RESULT";
......
...@@ -165,7 +165,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, ...@@ -165,7 +165,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
SELECT_LEX *lex_select_save= thd_arg->lex->current_select; SELECT_LEX *lex_select_save= thd_arg->lex->current_select;
SELECT_LEX *sl, *first_sl= first_select(); SELECT_LEX *sl, *first_sl= first_select();
select_result *tmp_result; select_result *tmp_result;
bool is_union; bool is_union_select;
TABLE *empty_table= 0; TABLE *empty_table= 0;
DBUG_ENTER("st_select_lex_unit::prepare"); DBUG_ENTER("st_select_lex_unit::prepare");
...@@ -203,11 +203,11 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, ...@@ -203,11 +203,11 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
thd_arg->lex->current_select= sl= first_sl; thd_arg->lex->current_select= sl= first_sl;
found_rows_for_union= first_sl->options & OPTION_FOUND_ROWS; found_rows_for_union= first_sl->options & OPTION_FOUND_ROWS;
is_union= first_sl->next_select() || fake_select_lex; is_union_select= is_union() || fake_select_lex;
/* Global option */ /* Global option */
if (is_union) if (is_union_select)
{ {
if (!(tmp_result= union_result= new select_union)) if (!(tmp_result= union_result= new select_union))
goto err; goto err;
...@@ -238,7 +238,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, ...@@ -238,7 +238,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
thd_arg->lex->current_select= sl; thd_arg->lex->current_select= sl;
can_skip_order_by= is_union && !(sl->braces && sl->explicit_limit); can_skip_order_by= is_union_select && !(sl->braces && sl->explicit_limit);
saved_error= join->prepare(&sl->ref_pointer_array, saved_error= join->prepare(&sl->ref_pointer_array,
(TABLE_LIST*) sl->table_list.first, (TABLE_LIST*) sl->table_list.first,
...@@ -251,7 +251,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, ...@@ -251,7 +251,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
(ORDER*) 0 : (ORDER *)sl->order_list.first, (ORDER*) 0 : (ORDER *)sl->order_list.first,
(ORDER*) sl->group_list.first, (ORDER*) sl->group_list.first,
sl->having, sl->having,
(is_union ? (ORDER*) 0 : (is_union_select ? (ORDER*) 0 :
(ORDER*) thd_arg->lex->proc_list.first), (ORDER*) thd_arg->lex->proc_list.first),
sl, this); sl, this);
/* There are no * in the statement anymore (for PS) */ /* There are no * in the statement anymore (for PS) */
...@@ -264,7 +264,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, ...@@ -264,7 +264,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
Use items list of underlaid select for derived tables to preserve Use items list of underlaid select for derived tables to preserve
information about fields lengths and exact types information about fields lengths and exact types
*/ */
if (!is_union) if (!is_union_select)
types= first_sl->item_list; types= first_sl->item_list;
else if (sl == first_sl) else if (sl == first_sl)
{ {
...@@ -307,7 +307,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, ...@@ -307,7 +307,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
} }
} }
if (is_union) if (is_union_select)
{ {
/* /*
Check that it was possible to aggregate Check that it was possible to aggregate
...@@ -639,7 +639,7 @@ void st_select_lex_unit::reinit_exec_mechanism() ...@@ -639,7 +639,7 @@ void st_select_lex_unit::reinit_exec_mechanism()
{ {
prepared= optimized= executed= 0; prepared= optimized= executed= 0;
#ifndef DBUG_OFF #ifndef DBUG_OFF
if (first_select()->next_select()) if (is_union())
{ {
List_iterator_fast<Item> it(item_list); List_iterator_fast<Item> it(item_list);
Item *field; Item *field;
...@@ -706,7 +706,6 @@ bool st_select_lex_unit::change_result(select_subselect *new_result, ...@@ -706,7 +706,6 @@ bool st_select_lex_unit::change_result(select_subselect *new_result,
List<Item> *st_select_lex_unit::get_unit_column_types() List<Item> *st_select_lex_unit::get_unit_column_types()
{ {
SELECT_LEX *sl= first_select(); SELECT_LEX *sl= first_select();
bool is_union= test(sl->next_select());
bool is_procedure= test(sl->join->procedure); bool is_procedure= test(sl->join->procedure);
if (is_procedure) if (is_procedure)
...@@ -717,7 +716,7 @@ List<Item> *st_select_lex_unit::get_unit_column_types() ...@@ -717,7 +716,7 @@ List<Item> *st_select_lex_unit::get_unit_column_types()
} }
if (is_union) if (is_union())
{ {
DBUG_ASSERT(prepared); DBUG_ASSERT(prepared);
/* Types are generated during prepare */ /* Types are generated during prepare */
......
...@@ -829,7 +829,7 @@ loop_out: ...@@ -829,7 +829,7 @@ loop_out:
UNION UNION
*/ */
if (view->updatable_view && if (view->updatable_view &&
!lex->select_lex.next_select() && !lex->select_lex.master_unit()->is_union() &&
!((TABLE_LIST*)lex->select_lex.table_list.first)->next_local && !((TABLE_LIST*)lex->select_lex.table_list.first)->next_local &&
find_table_in_global_list(lex->query_tables->next_global, find_table_in_global_list(lex->query_tables->next_global,
lex->query_tables->db, lex->query_tables->db,
......
...@@ -7817,7 +7817,7 @@ order_clause: ...@@ -7817,7 +7817,7 @@ order_clause:
yet. yet.
*/ */
SELECT_LEX *first_sl= unit->first_select(); SELECT_LEX *first_sl= unit->first_select();
if (!first_sl->next_select() && if (!unit->is_union() &&
(first_sl->order_list.elements || (first_sl->order_list.elements ||
first_sl->select_limit) && first_sl->select_limit) &&
unit->add_fake_select_lex(lex->thd)) unit->add_fake_select_lex(lex->thd))
......
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