mariadb/mysql-test/suite/versioning/r/delete_history.result
Aleksey Midenkov 0076dce2c8 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
2019-11-22 14:29:03 +03:00

131 lines
3.3 KiB
Text

create table t (a int);
delete history from t before system_time now();
ERROR HY000: Table `t` is not system-versioned
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);
update t set a=2;
set @test = 'correct';
create trigger trg_before before delete on t for each row set @test = 'incorrect';
create trigger trg_after after delete on t for each row set @test = 'incorrect';
delete history from t;
select @test from t;
@test
correct
drop table t;
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);
update t set a=11 where a=1;
set @ts1=now(6);
update t set a=22 where a=2;
select * from t for system_time all;
a
11
22
1
2
delete history from t before system_time timestamp @ts1;
select * from t for system_time all;
a
11
22
2
prepare stmt from 'delete history from t';
execute stmt;
drop prepare stmt;
select * from t for system_time all;
a
11
22
delete from t;
create or replace procedure truncate_sp()
begin
delete history from t before system_time timestamp now(6);
end~~
call truncate_sp;
select * from t for system_time all;
a
drop procedure truncate_sp;
# Truncate partitioned
create or replace table t (a int)
with system versioning
partition by system_time limit 1 (
partition p0 history,
partition p1 history,
partition pn current);
insert into t values (1);
update t set a= 2;
update t set a= 3;
delete history from t;
select * from t for system_time all;
a
3
# VIEW
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;
create or replace view v as select * from t;
delete history from v;
ERROR 42S02: 'v' is a view
create or replace table t (i int);
delete history from t;
ERROR HY000: Table `t` is not system-versioned
create or replace view v as select * from t;
delete history from v;
ERROR 42S02: 'v' is a view
prepare stmt from 'delete history from t';
ERROR HY000: Table `t` is not system-versioned
drop table t;
drop view v;
create or replace table t (i int);
create or replace view v as select * from t;
drop table v;
ERROR 42S02: 'test.v' is a view
lock table v write;
delete history from v before system_time now(6);
ERROR 42S02: 'v' is a view
unlock tables;
drop view v;
drop table t;
create table t1 (i int) with system versioning;
create procedure pr() delete history from t1 before system_time now();
call pr;
call pr;
drop procedure pr;
drop table t1;
#
# MDEV-19814 Assertion `update->n_fields < ulint(table->n_cols + table->n_v_cols)' on DELETE HISTORY
#
create or replace table t1 (
f varchar(1),
row_start SYS_TYPE as row start,
row_end SYS_TYPE as row end,
period for system_time (row_start, row_end))
with system versioning;
insert into t1 (f) values ('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h');
delete from t1;
delete history from t1;
drop table t1;
#
# MDEV-20186 Wrong result or Assertion on INSERT after DELETE HISTORY
#
create or replace table t1 (a int check (a > 0)) with system versioning;
delete history from t1;
insert into t1 values (1);
select * from t1;
a
1
drop table t1;