summaryrefslogtreecommitdiff
path: root/sql/sql_delete.cc
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2019-11-22 14:29:03 +0300
committerAleksey Midenkov <midenok@gmail.com>2019-11-22 14:29:03 +0300
commit0076dce2c89248b6c0252ec4385879194f9aadbf (patch)
tree1774fb25fcbe854aee956841ab28298029b548f6 /sql/sql_delete.cc
parenta14544260c33dcdb057d2f62c4aab33cb09ebcb1 (diff)
downloadmariadb-git-0076dce2c89248b6c0252ec4385879194f9aadbf.tar.gz
MDEV-18727 improve DML operation of System Versioning
MDEV-18957 UPDATE with LIMIT clause is wrong for versioned partitioned tables UPDATE, DELETE: replace linear search of current/historical records with vers_setup_conds(). Additional DML cases in view.test
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r--sql/sql_delete.cc65
1 files changed, 25 insertions, 40 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index e3d17174b8b..4245c843968 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -225,19 +225,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;
@@ -305,29 +297,7 @@ 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)
- {
- 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;
if (thd->lex->handle_list_of_derived(table_list, DT_MERGE_FOR_INSERT))
DBUG_RETURN(TRUE);
@@ -940,16 +910,36 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list,
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);
+ }
+
+/* 10.4:
+ if (table_list->has_period())
+ {
+ if (table_list->is_view_or_derived())
{
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))
+
+ 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 ((wild_num && setup_wild(thd, table_list, field_list, NULL, wild_num,
&select_lex->hidden_bit_fields)) ||
setup_fields(thd, Ref_ptr_array(),
@@ -1238,11 +1228,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++;