diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2019-11-25 17:24:09 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2019-11-25 17:24:09 +0300 |
commit | 0c05a2ed71ebf408e32f7fcdd358d756948d8a5d (patch) | |
tree | fabe919df6b001b22391f37c7a32a1e34a6bfd79 /sql/sql_delete.cc | |
parent | 7c7f9bef28aa566557da31402142f6dd8298ddd2 (diff) | |
parent | f9ceb0a67ffb20631c936a7e8e8776c000d677ac (diff) | |
download | mariadb-git-0c05a2ed71ebf408e32f7fcdd358d756948d8a5d.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r-- | sql/sql_delete.cc | 65 |
1 files changed, 17 insertions, 48 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index b12312041bd..29d6904f7f9 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -214,19 +214,11 @@ bool Update_plan::save_explain_data_intern(MEM_ROOT *mem_root, static bool record_should_be_deleted(THD *thd, TABLE *table, SQL_SELECT *sel, Explain_delete *explain, bool truncate_history) { - bool check_delete= true; - - if (table->versioned()) - { - bool historical= !table->vers_end_field()->is_max(); - check_delete= truncate_history ? historical : !historical; - } - explain->tracker.on_record_read(); thd->inc_examined_row_count(1); if (table->vfield) (void) table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_DELETE); - if (check_delete && (!sel || sel->skip_record(thd) > 0)) + if (!sel || sel->skip_record(thd) > 0) { explain->tracker.on_record_after_where(); return true; @@ -340,30 +332,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, THD_STAGE_INFO(thd, stage_init_update); - bool delete_history= table_list->vers_conditions.is_set(); - if (delete_history) - { - DBUG_ASSERT(!table_list->period_conditions.is_set()); - - if (table_list->is_view_or_derived()) - { - my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str); - DBUG_RETURN(true); - } - - DBUG_ASSERT(table_list->table); - DBUG_ASSERT(!conds || thd->stmt_arena->is_stmt_execute()); - - // conds could be cached from previous SP call - if (!conds) - { - if (select_lex->vers_setup_conds(thd, table_list)) - DBUG_RETURN(TRUE); - - conds= table_list->on_expr; - table_list->on_expr= NULL; - } - } + const bool delete_history= table_list->vers_conditions.delete_history; + DBUG_ASSERT(!(delete_history && table_list->period_conditions.is_set())); if (thd->lex->handle_list_of_derived(table_list, DT_MERGE_FOR_INSERT)) DBUG_RETURN(TRUE); @@ -1015,15 +985,11 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds, select_lex->leaf_tables, FALSE, DELETE_ACL, SELECT_ACL, TRUE)) DBUG_RETURN(TRUE); - if (table_list->vers_conditions.is_set()) + + if (table_list->vers_conditions.is_set() && table_list->is_view_or_derived()) { - if (table_list->is_view()) - { - my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str); - DBUG_RETURN(true); - } - if (select_lex->vers_setup_conds(thd, table_list)) - DBUG_RETURN(true); + my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str); + DBUG_RETURN(true); } if (table_list->has_period()) @@ -1034,11 +1000,19 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds, DBUG_RETURN(true); } - *conds= select_lex->period_setup_conds(thd, table_list, *conds); - if (!*conds) + if (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; + if (setup_returning_fields(thd, table_list) || setup_conds(thd, table_list, select_lex->leaf_tables, conds) || setup_ftfuncs(select_lex)) @@ -1332,11 +1306,6 @@ int multi_delete::send_data(List<Item> &values) if (table->status & (STATUS_NULL_ROW | STATUS_DELETED)) continue; - if (table->versioned() && !table->vers_end_field()->is_max()) - { - continue; - } - table->file->position(table->record[0]); found++; |