[Commits] b19cf47: Fixed problems of INSERTs for prepared statements.
revision-id: b19cf47ce0b1659a0ad91fe1ed5c22df0bc47969 (mariadb-10.3.5-112-gb19cf47) parent(s): b1f765d14b3bd0e3e2dbc874293dad77d5ad791c author: Igor Babaev committer: Igor Babaev timestamp: 2018-04-07 13:45:49 -0700 message: Fixed problems of INSERTs for prepared statements. --- sql/sql_lex.cc | 66 +++++++++++++++++++++++++++++---------------------------- sql/sql_lex.h | 2 ++ sql/sql_yacc.yy | 3 ++- 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2765a46..75059bc 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -8480,51 +8480,53 @@ bool LEX::insert_select_hack(SELECT_LEX *sel) DBUG_ASSERT(first_select_lex() == &builtin_select); DBUG_ASSERT(sel != NULL); - if (builtin_select.first_inner_unit()) - { - sel->link_chain_down(builtin_select.first_inner_unit()); - builtin_select.slave= NULL; - } - - if (builtin_select.link_prev) - { - if ((*builtin_select.link_prev= builtin_select.link_next)) - ((st_select_lex *)builtin_select.link_next)->link_prev= - builtin_select.link_prev; - builtin_select.link_prev= NULL; // indicator of removal - } - - set_main_unit(sel->master_unit()); - - DBUG_ASSERT(builtin_select.table_list.elements == 1); - TABLE_LIST *insert_table= builtin_select.table_list.first; - - if (!(insert_table->next_local= sel->table_list.first)) - { - sel->table_list.next= &insert_table->next_local; - } - sel->table_list.first= insert_table; - sel->table_list.elements++; - insert_table->select_lex= sel; - - sel->context.first_name_resolution_table= insert_table; - builtin_select.context= sel->context; - change_item_list_context(&field_list, &sel->context); - if (sel->tvc && !sel->next_select() && (sql_command == SQLCOM_INSERT_SELECT || sql_command == SQLCOM_REPLACE_SELECT)) { - DBUG_PRINT("info", ("'Unual' INSERT detected")); + DBUG_PRINT("info", ("'Usual' INSERT detected")); many_values= sel->tvc->lists_of_values; sel->options= sel->tvc->select_options; sel->tvc= NULL; + // sel->fast_exclude(); if (sql_command == SQLCOM_INSERT_SELECT) sql_command= SQLCOM_INSERT; else sql_command= SQLCOM_REPLACE; } + else + { + if (builtin_select.first_inner_unit()) + { + sel->link_chain_down(builtin_select.first_inner_unit()); + builtin_select.slave= NULL; + } + + if (builtin_select.link_prev) + { + if ((*builtin_select.link_prev= builtin_select.link_next)) + ((st_select_lex *)builtin_select.link_next)->link_prev= + builtin_select.link_prev; + builtin_select.link_prev= NULL; // indicator of removal + } + set_main_unit(sel->master_unit()); + + DBUG_ASSERT(builtin_select.table_list.elements == 1); + TABLE_LIST *insert_table= builtin_select.table_list.first; + + if (!(insert_table->next_local= sel->table_list.first)) + { + sel->table_list.next= &insert_table->next_local; + } + sel->table_list.first= insert_table; + sel->table_list.elements++; + insert_table->select_lex= sel; + + sel->context.first_name_resolution_table= insert_table; + builtin_select.context= sel->context; + change_item_list_context(&field_list, &sel->context); + } for (SELECT_LEX *sel= all_selects_list; sel; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 724559a..4049ac8 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -3120,6 +3120,8 @@ struct LEX: public Query_tables_list /* System Versioning */ vers_select_conds_t vers_conditions; + st_select_lex *tvc_select; + inline void free_set_stmt_mem_root() { DBUG_ASSERT(!is_arena_for_set_stmt()); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 9372269..7fb0ee7 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -9245,11 +9245,12 @@ table_value_constructor: MYSQL_YYABORT; sel->init_select(); sel->braces= FALSE; // just initialisation + lex->tvc_select= lex->pop_select(); // above TVC select } values_list { LEX *lex=Lex; - $$= lex->pop_select(); // above TVC select + $$= lex->tvc_select; if (!($$->tvc= new (lex->thd->mem_root) table_value_constr(lex->many_values, $$,
participants (1)
-
IgorBabaev