1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-25468 DELETE HISTORY may delete current data on system-versioned table

Item_func_history (is_history()) is a bool function that checks if the
row is the history row by checking row_end->is_max(). The argument to
this function must be row_end system field.

Added the above function to conjunction with SYSTEM_TIME_BEFORE
versioning condition.
This commit is contained in:
Aleksey Midenkov
2021-04-21 22:14:08 +03:00
parent 29b2f3dbb5
commit 6d73282b13
5 changed files with 105 additions and 2 deletions

View File

@ -928,7 +928,8 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
cond3= newx Item_func_le(thd, point_in_time1, point_in_time2);
break;
case SYSTEM_TIME_BEFORE:
cond1= newx Item_func_lt(thd, row_end, point_in_time1);
cond1= newx Item_func_history(thd, row_end);
cond2= newx Item_func_lt(thd, row_end, point_in_time1);
break;
default:
DBUG_ASSERT(0);
@ -978,7 +979,8 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
trx_id0= vers_conditions.start.unit == VERS_TIMESTAMP
? newx Item_func_trt_id(thd, point_in_time1, TR_table::FLD_TRX_ID, true)
: point_in_time1;
cond1= newx Item_func_trt_trx_sees(thd, trx_id0, row_end);
cond1= newx Item_func_history(thd, row_end);
cond2= newx Item_func_trt_trx_sees(thd, trx_id0, row_end);
break;
default:
DBUG_ASSERT(0);