mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-15979 DELETE HISTORY from a table with transaction-precise versioning causes Assertion `table_list->vers_conditions.type == SYSTEM_TIME_BEFORE' failure
* Fix versioning.truncate,trx_id to create transaction-based tables * Fix SYSTEM_TIME_BEFORE condition for VERS_TRX_ID
This commit is contained in:
committed by
Sergei Golubchik
parent
60319afff7
commit
21eccff625
@ -1,7 +1,12 @@
|
|||||||
create table t (a int);
|
create table t (a int);
|
||||||
delete history from t before system_time now();
|
delete history from t before system_time now();
|
||||||
ERROR HY000: Table `t` is not system-versioned
|
ERROR HY000: Table `t` is not system-versioned
|
||||||
create or replace table t (a int) with system versioning;
|
create or replace table t (
|
||||||
|
a int,
|
||||||
|
row_start SYS_TYPE as row start invisible,
|
||||||
|
row_end SYS_TYPE as row end invisible,
|
||||||
|
period for system_time (row_start, row_end))
|
||||||
|
with system versioning;
|
||||||
insert into t values (1);
|
insert into t values (1);
|
||||||
update t set a=2;
|
update t set a=2;
|
||||||
set @test = 'correct';
|
set @test = 'correct';
|
||||||
@ -12,7 +17,12 @@ select @test from t;
|
|||||||
@test
|
@test
|
||||||
correct
|
correct
|
||||||
drop table t;
|
drop table t;
|
||||||
create table t (a int) with system versioning;
|
create or replace table t (
|
||||||
|
a int,
|
||||||
|
row_start SYS_TYPE as row start invisible,
|
||||||
|
row_end SYS_TYPE as row end invisible,
|
||||||
|
period for system_time (row_start, row_end))
|
||||||
|
with system versioning;
|
||||||
insert into t values (1), (2);
|
insert into t values (1), (2);
|
||||||
update t set a=11 where a=1;
|
update t set a=11 where a=1;
|
||||||
set @ts1=now(6);
|
set @ts1=now(6);
|
||||||
@ -48,7 +58,6 @@ drop procedure truncate_sp;
|
|||||||
# Truncate partitioned
|
# Truncate partitioned
|
||||||
create or replace table t (a int)
|
create or replace table t (a int)
|
||||||
with system versioning
|
with system versioning
|
||||||
engine myisam
|
|
||||||
partition by system_time limit 1 (
|
partition by system_time limit 1 (
|
||||||
partition p0 history,
|
partition p0 history,
|
||||||
partition p1 history,
|
partition p1 history,
|
||||||
@ -61,7 +70,12 @@ select * from t for system_time all;
|
|||||||
a
|
a
|
||||||
3
|
3
|
||||||
# VIEW
|
# VIEW
|
||||||
create or replace table t (i int) with system versioning;
|
create or replace table t (
|
||||||
|
i int,
|
||||||
|
row_start SYS_TYPE as row start invisible,
|
||||||
|
row_end SYS_TYPE as row end invisible,
|
||||||
|
period for system_time (row_start, row_end))
|
||||||
|
with system versioning;
|
||||||
delete history from t;
|
delete history from t;
|
||||||
create or replace view v as select * from t;
|
create or replace view v as select * from t;
|
||||||
delete history from v;
|
delete history from v;
|
||||||
@ -86,3 +100,5 @@ ERROR 42S02: 'v' is a view
|
|||||||
unlock tables;
|
unlock tables;
|
||||||
drop view v;
|
drop view v;
|
||||||
drop table t;
|
drop table t;
|
||||||
|
drop database test;
|
||||||
|
create database test;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
--source suite/versioning/common.inc
|
||||||
--source include/have_partition.inc
|
--source include/have_partition.inc
|
||||||
--source suite/versioning/engines.inc
|
--source suite/versioning/engines.inc
|
||||||
|
|
||||||
@ -6,7 +7,13 @@ create table t (a int);
|
|||||||
delete history from t before system_time now();
|
delete history from t before system_time now();
|
||||||
|
|
||||||
# TRUNCATE is not DELETE and trigger must not be called.
|
# TRUNCATE is not DELETE and trigger must not be called.
|
||||||
create or replace table t (a int) with system versioning;
|
--replace_result $sys_datatype_expl SYS_TYPE
|
||||||
|
eval create or replace table t (
|
||||||
|
a int,
|
||||||
|
row_start $sys_datatype_expl as row start invisible,
|
||||||
|
row_end $sys_datatype_expl as row end invisible,
|
||||||
|
period for system_time (row_start, row_end))
|
||||||
|
with system versioning;
|
||||||
insert into t values (1);
|
insert into t values (1);
|
||||||
update t set a=2;
|
update t set a=2;
|
||||||
set @test = 'correct';
|
set @test = 'correct';
|
||||||
@ -16,7 +23,13 @@ delete history from t;
|
|||||||
select @test from t;
|
select @test from t;
|
||||||
drop table t;
|
drop table t;
|
||||||
|
|
||||||
create table t (a int) with system versioning;
|
--replace_result $sys_datatype_expl SYS_TYPE
|
||||||
|
eval create or replace table t (
|
||||||
|
a int,
|
||||||
|
row_start $sys_datatype_expl as row start invisible,
|
||||||
|
row_end $sys_datatype_expl as row end invisible,
|
||||||
|
period for system_time (row_start, row_end))
|
||||||
|
with system versioning;
|
||||||
insert into t values (1), (2);
|
insert into t values (1), (2);
|
||||||
update t set a=11 where a=1;
|
update t set a=11 where a=1;
|
||||||
--real_sleep 0.01
|
--real_sleep 0.01
|
||||||
@ -45,7 +58,6 @@ drop procedure truncate_sp;
|
|||||||
--echo # Truncate partitioned
|
--echo # Truncate partitioned
|
||||||
create or replace table t (a int)
|
create or replace table t (a int)
|
||||||
with system versioning
|
with system versioning
|
||||||
engine myisam
|
|
||||||
partition by system_time limit 1 (
|
partition by system_time limit 1 (
|
||||||
partition p0 history,
|
partition p0 history,
|
||||||
partition p1 history,
|
partition p1 history,
|
||||||
@ -57,7 +69,13 @@ delete history from t;
|
|||||||
select * from t for system_time all;
|
select * from t for system_time all;
|
||||||
|
|
||||||
--echo # VIEW
|
--echo # VIEW
|
||||||
create or replace table t (i int) with system versioning;
|
--replace_result $sys_datatype_expl SYS_TYPE
|
||||||
|
eval create or replace table t (
|
||||||
|
i int,
|
||||||
|
row_start $sys_datatype_expl as row start invisible,
|
||||||
|
row_end $sys_datatype_expl as row end invisible,
|
||||||
|
period for system_time (row_start, row_end))
|
||||||
|
with system versioning;
|
||||||
delete history from t;
|
delete history from t;
|
||||||
create or replace view v as select * from t;
|
create or replace view v as select * from t;
|
||||||
--error ER_IT_IS_A_VIEW
|
--error ER_IT_IS_A_VIEW
|
||||||
@ -88,3 +106,6 @@ delete history from v before system_time now(6);
|
|||||||
unlock tables;
|
unlock tables;
|
||||||
drop view v;
|
drop view v;
|
||||||
drop table t;
|
drop table t;
|
||||||
|
|
||||||
|
drop database test;
|
||||||
|
create database test;
|
||||||
|
@ -123,7 +123,7 @@ Item_func_trt_id::get_by_commit_ts(MYSQL_TIME &commit_ts, bool backwards)
|
|||||||
TR_table trt(thd);
|
TR_table trt(thd);
|
||||||
null_value= !trt.query(commit_ts, backwards);
|
null_value= !trt.query(commit_ts, backwards);
|
||||||
if (null_value)
|
if (null_value)
|
||||||
return 0;
|
return backwards ? ULONGLONG_MAX : 0;
|
||||||
|
|
||||||
return trt[trt_field]->val_int();
|
return trt[trt_field]->val_int();
|
||||||
}
|
}
|
||||||
|
@ -324,13 +324,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
|||||||
DBUG_ASSERT(!conds);
|
DBUG_ASSERT(!conds);
|
||||||
conds= table_list->on_expr;
|
conds= table_list->on_expr;
|
||||||
table_list->on_expr= NULL;
|
table_list->on_expr= NULL;
|
||||||
|
|
||||||
// trx_sees() in InnoDB reads row_start
|
|
||||||
if (!table->versioned(VERS_TIMESTAMP))
|
|
||||||
{
|
|
||||||
DBUG_ASSERT(table_list->vers_conditions.type == SYSTEM_TIME_BEFORE);
|
|
||||||
bitmap_set_bit(table->read_set, table->vers_end_field()->field_index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT))
|
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT))
|
||||||
|
Reference in New Issue
Block a user