diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_subselect.cc | 6 | ||||
-rw-r--r-- | sql/sql_derived.cc | 4 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 11 | ||||
-rw-r--r-- | sql/sql_union.cc | 19 | ||||
-rw-r--r-- | sql/sql_view.cc | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 2 |
7 files changed, 22 insertions, 24 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 79b09967a9d..812d3c222c0 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -82,7 +82,7 @@ void Item_subselect::init(st_select_lex *select_lex, parsing_place= (outer_select->in_sum_expr ? NO_MATTER : outer_select->parsing_place); - if (select_lex->next_select()) + if (unit->is_union()) engine= new subselect_union_engine(unit, result, this); else engine= new subselect_single_select_engine(select_lex, result, this); @@ -412,7 +412,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join) SELECT_LEX *select_lex= join->select_lex; 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->item_list.elements == 1 && !select_lex->item_list.head()->with_sum_func && @@ -1147,7 +1147,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, else { 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() diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 89bd7958c86..ea7545fe5cb 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -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_union *derived_result= orig_table_list->derived_result; SELECT_LEX *save_current_select= lex->current_select; - bool is_union= first_select->next_select() && - first_select->next_select()->linkage == UNION_TYPE; - if (is_union) + if (unit->is_union()) { // execute union without clean up res= unit->exec(); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9d02053ec00..31cf9e18959 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5893,7 +5893,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.select_lex= fake_select_lex; - if (!first_sl->next_select()) + if (!is_union()) { /* This works only for diff --git a/sql/sql_select.cc b/sql/sql_select.cc index da2c8e96b0f..14423c949e5 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -231,7 +231,8 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, register SELECT_LEX *select_lex = &lex->select_lex; 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); else { @@ -442,7 +443,7 @@ JOIN::prepare(Item ***rref_pointer_array, select_lex= select_lex_arg; select_lex->join= this; 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; /* @@ -1191,7 +1192,7 @@ JOIN::optimize() if (!group_list && !order && unit->item && unit->item->substype() == Item_subselect::IN_SUBS && tables == 1 && conds && - !unit->first_select()->next_select()) + !unit->is_union()) { if (!having) { @@ -3165,7 +3166,7 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level, if (!join->group_list && !join->order && join->unit->item && join->unit->item->substype() == Item_subselect::IN_SUBS && - !join->unit->first_select()->next_select()) + !join->unit->is_union()) { KEY_FIELD *save= *key_fields; 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) "UNION"))); 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->type= "UNION RESULT"; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index bc81679a7fd..2a1db422058 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -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 *sl, *first_sl= first_select(); select_result *tmp_result; - bool is_union; + bool is_union_select; TABLE *empty_table= 0; DBUG_ENTER("st_select_lex_unit::prepare"); @@ -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; 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 */ - if (is_union) + if (is_union_select) { if (!(tmp_result= union_result= new select_union)) goto err; @@ -238,7 +238,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, 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, (TABLE_LIST*) sl->table_list.first, @@ -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*) sl->group_list.first, sl->having, - (is_union ? (ORDER*) 0 : + (is_union_select ? (ORDER*) 0 : (ORDER*) thd_arg->lex->proc_list.first), sl, this); /* 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, Use items list of underlaid select for derived tables to preserve information about fields lengths and exact types */ - if (!is_union) + if (!is_union_select) types= first_sl->item_list; else if (sl == first_sl) { @@ -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 @@ -639,7 +639,7 @@ void st_select_lex_unit::reinit_exec_mechanism() { prepared= optimized= executed= 0; #ifndef DBUG_OFF - if (first_select()->next_select()) + if (is_union()) { List_iterator_fast<Item> it(item_list); Item *field; @@ -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() { SELECT_LEX *sl= first_select(); - bool is_union= test(sl->next_select()); bool is_procedure= test(sl->join->procedure); if (is_procedure) @@ -717,7 +716,7 @@ List<Item> *st_select_lex_unit::get_unit_column_types() } - if (is_union) + if (is_union()) { DBUG_ASSERT(prepared); /* Types are generated during prepare */ diff --git a/sql/sql_view.cc b/sql/sql_view.cc index ee99a2974f4..f796a05924a 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -818,7 +818,7 @@ loop_out: UNION */ 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 && find_table_in_global_list(lex->query_tables->next_global, lex->query_tables->db, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 0c7d2fc2187..87cd33117dc 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7817,7 +7817,7 @@ order_clause: yet. */ SELECT_LEX *first_sl= unit->first_select(); - if (!first_sl->next_select() && + if (!unit->is_union() && (first_sl->order_list.elements || first_sl->select_limit) && unit->add_fake_select_lex(lex->thd)) |