[Commits] f748eab: Not to be pushed.
revision-id: f748eab1db45c2e4ffeb4e8dfa6c6462c030930c (mariadb-10.10.1-7-gf748eab) parent(s): 0cfe6acccf1d41f58d78dedbcbcc213baa5b657d author: Igor Babaev committer: Igor Babaev timestamp: 2022-08-17 18:34:52 -0700 message: Not to be pushed. --- sql/sql_delete.cc | 2 +- sql/sql_lex.cc | 2 +- sql/sql_update.cc | 173 ------------------------------------------------------ sql/sql_yacc.yy | 2 +- 4 files changed, 3 insertions(+), 176 deletions(-) diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 646f043..8acc502 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -1537,7 +1537,7 @@ bool Sql_cmd_delete::prepare_inner(THD *thd) } if (!(result= new (thd->mem_root) multi_delete(thd, aux_tables, - lex->table_count))) + lex->table_count_update))) { DBUG_RETURN(TRUE); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index bc11a51..8f9d042 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1304,7 +1304,7 @@ void LEX::start(THD *thd_arg) wild= 0; exchange= 0; - table_count= 0; + table_count_update= 0; DBUG_VOID_RETURN; } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index b1dab6c..69fa92f 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -410,31 +410,8 @@ bool Sql_cmd_update::update_single_table(THD *thd) if (table->default_field) table->mark_default_fields_for_write(false); -<<<<<<< 87e8463e0454a04c2bbaa38d44227c491fb07dc1 -#ifndef NO_EMBEDDED_ACCESS_CHECKS - /* Check values */ - table_list->grant.want_privilege= table->grant.want_privilege= - (SELECT_ACL & ~table->grant.privilege); -#endif - if (setup_fields(thd, Ref_ptr_array(), values, MARK_COLUMNS_READ, 0, NULL, 0)) - { - free_underlaid_joins(thd, select_lex); - DBUG_RETURN(1); /* purecov: inspected */ - } - - if (table_list->table->check_assignability_explicit_fields(fields, values, - ignore)) - DBUG_RETURN(true); - - if (check_unique_table(thd, table_list)) - DBUG_RETURN(TRUE); - - switch_to_nullable_trigger_fields(fields, table); - switch_to_nullable_trigger_fields(values, table); -======= switch_to_nullable_trigger_fields(*fields, table); switch_to_nullable_trigger_fields(*values, table); ->>>>>>> MDEV-28883 Re-design the upper level of handling UPDATE and DELETE statements /* Apply the IN=>EXISTS transformation to all subqueries and optimize them */ if (select_lex->optimize_unflattened_subqueries(false)) @@ -1682,156 +1659,6 @@ bool Multiupdate_prelocking_strategy::handle_end(THD *thd) DBUG_RETURN(0); } -<<<<<<< 87e8463e0454a04c2bbaa38d44227c491fb07dc1 -/* - make update specific preparation and checks after opening tables - - SYNOPSIS - mysql_multi_update_prepare() - thd thread handler - - RETURN - FALSE OK - TRUE Error -*/ - -int mysql_multi_update_prepare(THD *thd) -{ - LEX *lex= thd->lex; - TABLE_LIST *table_list= lex->query_tables; - TABLE_LIST *tl; - Multiupdate_prelocking_strategy prelocking_strategy; - uint table_count= lex->table_count_update; - DBUG_ENTER("mysql_multi_update_prepare"); - - /* - Open tables and create derived ones, but do not lock and fill them yet. - - During prepare phase acquire only S metadata locks instead of SW locks to - keep prepare of multi-UPDATE compatible with concurrent LOCK TABLES WRITE - and global read lock. - - Don't evaluate any subqueries even if constant, because - tables aren't locked yet. - */ - lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_DERIVED; - if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI) - { - if (open_tables(thd, &table_list, &table_count, - thd->stmt_arena->is_stmt_prepare() ? MYSQL_OPEN_FORCE_SHARED_MDL : 0, - &prelocking_strategy)) - DBUG_RETURN(TRUE); - } - else - { - /* following need for prepared statements, to run next time multi-update */ - thd->lex->sql_command= SQLCOM_UPDATE_MULTI; - prelocking_strategy.reset(thd); - if (prelocking_strategy.handle_end(thd)) - DBUG_RETURN(TRUE); - } - - /* now lock and fill tables */ - if (!thd->stmt_arena->is_stmt_prepare() && - lock_tables(thd, table_list, table_count, 0)) - DBUG_RETURN(TRUE); - - lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_DERIVED; - - (void) read_statistics_for_tables_if_needed(thd, table_list); - /* @todo: downgrade the metadata locks here. */ - - /* - Check that we are not using table that we are updating, but we should - skip all tables of UPDATE SELECT itself - */ - lex->first_select_lex()->exclude_from_table_unique_test= TRUE; - /* We only need SELECT privilege for columns in the values list */ - List_iterator<TABLE_LIST> ti(lex->first_select_lex()->leaf_tables); - while ((tl= ti++)) - { - if (tl->is_jtbm()) - continue; - TABLE *table= tl->table; - TABLE_LIST *tlist; - if (!(tlist= tl->top_table())->derived) - { - tlist->grant.want_privilege= - (SELECT_ACL & ~tlist->grant.privilege); - table->grant.want_privilege= (SELECT_ACL & ~table->grant.privilege); - } - DBUG_PRINT("info", ("table: %s want_privilege: %llx", tl->alias.str, - (longlong) table->grant.want_privilege)); - } - /* - Set exclude_from_table_unique_test value back to FALSE. It is needed for - further check in multi_update::prepare whether to use record cache. - */ - lex->first_select_lex()->exclude_from_table_unique_test= FALSE; - - if (lex->save_prep_leaf_tables()) - DBUG_RETURN(TRUE); - - DBUG_RETURN (FALSE); -} - - -/* - Setup multi-update handling and call SELECT to do the join -*/ - -bool mysql_multi_update(THD *thd, TABLE_LIST *table_list, List<Item> *fields, - List<Item> *values, COND *conds, ulonglong options, - enum enum_duplicates handle_duplicates, - bool ignore, SELECT_LEX_UNIT *unit, - SELECT_LEX *select_lex, multi_update **result) -{ - bool res; - DBUG_ENTER("mysql_multi_update"); - - if (!(*result= new (thd->mem_root) multi_update(thd, table_list, - &thd->lex->first_select_lex()->leaf_tables, - fields, values, handle_duplicates, ignore))) - { - DBUG_RETURN(TRUE); - } - - if ((*result)->init(thd)) - DBUG_RETURN(1); - - thd->abort_on_warning= !ignore && thd->is_strict_mode(); - List<Item> total_list; - - if (setup_tables(thd, &select_lex->context, &select_lex->top_join_list, - table_list, select_lex->leaf_tables, FALSE, FALSE)) - DBUG_RETURN(1); - - if (select_lex->vers_setup_conds(thd, table_list)) - DBUG_RETURN(1); - - res= mysql_select(thd, - table_list, total_list, conds, - select_lex->order_list.elements, - select_lex->order_list.first, NULL, NULL, NULL, - options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | - OPTION_SETUP_TABLES_DONE, - *result, unit, select_lex); - - DBUG_PRINT("info",("res: %d report_error: %d", res, (int) thd->is_error())); - res|= thd->is_error(); - if (unlikely(res)) - (*result)->abort_result_set(); - else - { - if (thd->lex->describe || thd->lex->analyze_stmt) - res= thd->lex->explain->send_explain(thd); - } - thd->abort_on_warning= 0; - DBUG_RETURN(res); -} - -======= ->>>>>>> MDEV-28883 Re-design the upper level of handling UPDATE and DELETE statements multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list, List<TABLE_LIST> *leaves_list, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 20b4086..13f0dbd 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -13385,7 +13385,7 @@ delete_single_table: MYSQL_YYABORT; Select->table_list.save_and_clear(&Lex->auxiliary_table_list); /* Save the number of auxiliary tables */ - Lex->table_count= 1; + Lex->table_count_update= 1; Lex->query_tables= 0; Lex->query_tables_last= &Lex->query_tables;
participants (1)
-
IgorBabaev