diff options
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d193370eef7..10b05a0550d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2911,9 +2911,9 @@ mysql_init_query(THD *thd) thd->select_number= thd->lex.select_lex.select_number= 1; thd->lex.value_list.empty(); thd->free_list= 0; - thd->lex.select= &thd->lex.select_lex; + thd->lex.current_select= &thd->lex.select_lex; thd->lex.olap=thd->lex.describe=0; - thd->lex.select->olap= UNSPECIFIED_OLAP_TYPE; + thd->lex.select_lex.olap= UNSPECIFIED_OLAP_TYPE; thd->fatal_error= 0; // Safety thd->total_warn_count=0; // Warnings for this query thd->last_insert_id_used= thd->query_start_used= thd->insert_id_used=0; @@ -2927,7 +2927,8 @@ mysql_init_query(THD *thd) void mysql_init_select(LEX *lex) { - SELECT_LEX *select_lex= lex->select; + SELECT_LEX *select_lex= lex->current_select->select_lex(); + DBUG_ASSERT(select_lex->linkage != GLOBAL_OPTIONS_TYPE); select_lex->init_select(); select_lex->master_unit()->select_limit= select_lex->select_limit= lex->thd->variables.select_limit; @@ -2941,7 +2942,7 @@ mysql_init_select(LEX *lex) bool mysql_new_select(LEX *lex, bool move_down) { - SELECT_LEX *select_lex = (SELECT_LEX *) lex->thd->calloc(sizeof(SELECT_LEX)); + SELECT_LEX *select_lex = new SELECT_LEX(); select_lex->select_number= ++lex->thd->select_number; if (!select_lex) return 1; @@ -2950,21 +2951,22 @@ mysql_new_select(LEX *lex, bool move_down) if (move_down) { /* first select_lex of subselect or derived table */ - SELECT_LEX_UNIT *unit= - (SELECT_LEX_UNIT *) lex->thd->calloc(sizeof(SELECT_LEX_UNIT)); + SELECT_LEX_UNIT *unit= new SELECT_LEX_UNIT(); if (!unit) return 1; unit->init_query(); unit->init_select(); - unit->include_down(lex->select); + unit->include_down(lex->current_select); select_lex->include_down(unit); } else - select_lex->include_neighbour(lex->select); + select_lex->include_neighbour(lex->current_select); select_lex->master_unit()->global_parameters= select_lex; - select_lex->include_global(lex->select->next_select_in_list_addr()); - lex->select= select_lex; + DBUG_ASSERT(lex->current_select->linkage != GLOBAL_OPTIONS_TYPE); + select_lex->include_global(lex->current_select->select_lex()-> + next_select_in_list_addr()); + lex->current_select= select_lex; return 0; } @@ -3000,10 +3002,10 @@ void mysql_init_multi_delete(LEX *lex) { lex->sql_command= SQLCOM_DELETE_MULTI; mysql_init_select(lex); - lex->select->select_limit= lex->select->master_unit()->select_limit_cnt= + lex->select_lex.select_limit= lex->unit.select_limit_cnt= HA_POS_ERROR; lex->auxilliary_table_list= lex->select_lex.table_list; - lex->select->init_query(); + lex->select_lex.init_query(); } @@ -3413,12 +3415,12 @@ bool add_to_list(SQL_LIST &list,Item *item,bool asc) } -TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, - bool updating, - thr_lock_type flags, - List<String> *use_index, - List<String> *ignore_index - ) +TABLE_LIST *st_select_lex::add_table_to_list(Table_ident *table, + LEX_STRING *alias, + bool updating, + thr_lock_type flags, + List<String> *use_index, + List<String> *ignore_index) { register TABLE_LIST *ptr; THD *thd=current_thd; @@ -3480,7 +3482,7 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, /* check that used name is unique */ if (flags != TL_IGNORE) { - for (TABLE_LIST *tables=(TABLE_LIST*) thd->lex.select->table_list.first ; + for (TABLE_LIST *tables=(TABLE_LIST*) table_list.first ; tables ; tables=tables->next) { @@ -3491,7 +3493,7 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, } } } - link_in_list(&thd->lex.select->table_list,(byte*) ptr,(byte**) &ptr->next); + link_in_list(&table_list, (byte*) ptr, (byte**) &ptr->next); DBUG_RETURN(ptr); } @@ -3694,7 +3696,7 @@ static bool append_file_to_dir(THD *thd, char **filename_ptr, char *table_name) bool check_simple_select() { THD *thd= current_thd; - if (thd->lex.select != &thd->lex.select_lex) + if (thd->lex.current_select != &thd->lex.select_lex) { char command[80]; strmake(command, thd->lex.yylval->symbol.str, |