From 33f55789d354b0fccf5234027dc0bd66cbd0c539 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Mon, 25 Nov 2019 16:01:43 +0300 Subject: MDEV-18727 improve DML operation of System Versioning (10.4) UPDATE, DELETE: replace linear search of current/historical records with vers_setup_conds(). Additional DML cases in view.test --- sql/sql_update.cc | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'sql/sql_update.cc') diff --git a/sql/sql_update.cc b/sql/sql_update.cc index f5bb298fdba..590a4f8bae1 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -960,11 +960,6 @@ update_begin: THD_STAGE_INFO(thd, stage_updating); while (!(error=info.read_record()) && !thd->killed) { - if (table->versioned() && !table->vers_end_field()->is_max()) - { - continue; - } - explain->tracker.on_record_read(); thd->inc_examined_row_count(1); if (!select || select->skip_record(thd) > 0) @@ -1373,12 +1368,18 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list, thd->lex->allow_sum_func.clear_all(); - if (table_list->has_period()) - { - *conds= select_lex->period_setup_conds(thd, table_list, *conds); - if (!*conds) + if (table_list->has_period() && + select_lex->period_setup_conds(thd, table_list)) DBUG_RETURN(true); - } + + DBUG_ASSERT(table_list->table); + // conds could be cached from previous SP call + DBUG_ASSERT(!table_list->vers_conditions.is_set() || + !*conds || thd->stmt_arena->is_stmt_execute()); + if (select_lex->vers_setup_conds(thd, table_list)) + DBUG_RETURN(TRUE); + + *conds= select_lex->where; /* We do not call DT_MERGE_FOR_INSERT because it has no sense for simple @@ -1900,6 +1901,9 @@ bool mysql_multi_update(THD *thd, TABLE_LIST *table_list, List *fields, thd->abort_on_warning= !ignore && thd->is_strict_mode(); List total_list; + if (select_lex->vers_setup_conds(thd, table_list)) + DBUG_RETURN(1); + res= mysql_select(thd, table_list, select_lex->with_wild, total_list, conds, select_lex->order_list.elements, @@ -2459,11 +2463,6 @@ int multi_update::send_data(List ¬_used_values) if (table->status & (STATUS_NULL_ROW | STATUS_UPDATED)) continue; - if (table->versioned() && !table->vers_end_field()->is_max()) - { - continue; - } - if (table == table_to_update) { /* -- cgit v1.2.1