-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.6: truncate history feature [closes #96]
- Loading branch information
Showing
15 changed files
with
301 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
create table t (a int); | ||
truncate t for system_time all; | ||
ERROR HY000: System Versioning required: `FOR SYSTEM_TIME` query | ||
create procedure truncate_history_of_t() | ||
begin | ||
prepare stmt from 'truncate t for system_time timestamp between \'1-1-1\' and now(6)'; | ||
execute stmt; | ||
drop prepare stmt; | ||
end~~ | ||
create or replace table t (a int) with system versioning; | ||
insert into t values (1); | ||
update t set a=2; | ||
select * from t for system_time all; | ||
a | ||
2 | ||
1 | ||
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'; | ||
truncate t for system_time all; | ||
select * from t for system_time all; | ||
a | ||
2 | ||
select @test from t; | ||
@test | ||
correct | ||
drop trigger trg_before; | ||
drop trigger trg_after; | ||
update t set a=3; | ||
update t set a=4; | ||
truncate t for system_time as of timestamp now(6); | ||
select * from t for system_time all; | ||
a | ||
4 | ||
2 | ||
3 | ||
truncate t for system_time timestamp between '1-1-1' and now(6); | ||
select * from t for system_time all; | ||
a | ||
4 | ||
update t set a=5; | ||
truncate t for system_time timestamp from '1-1-1' to now(6); | ||
select * from t for system_time all; | ||
a | ||
5 | ||
update t set a=6; | ||
call truncate_history_of_t(); | ||
select * from t for system_time all; | ||
a | ||
6 | ||
set @ts1 = now(6); | ||
update t set a=7; | ||
set @ts2 = now(6); | ||
update t set a=8; | ||
truncate t for system_time timestamp from '1-1-1' to @ts1; | ||
select * from t for system_time all; | ||
a | ||
8 | ||
7 | ||
update t set a=9; | ||
truncate t for system_time timestamp between '1-1-1' and @ts2; | ||
select * from t for system_time all; | ||
a | ||
9 | ||
8 | ||
create or replace table t (a int) with system versioning engine=innodb; | ||
insert into t values (1); | ||
update t set a=2; | ||
select * from t for system_time all; | ||
a | ||
2 | ||
1 | ||
truncate t for system_time all; | ||
select * from t for system_time all; | ||
a | ||
2 | ||
update t set a=3; | ||
update t set a=4; | ||
truncate t for system_time as of timestamp now(6); | ||
select * from t for system_time all; | ||
a | ||
4 | ||
2 | ||
3 | ||
truncate t for system_time timestamp between '1-1-1' and now(6); | ||
select * from t for system_time all; | ||
a | ||
4 | ||
update t set a=5; | ||
truncate t for system_time timestamp from '1-1-1' to now(6); | ||
select * from t for system_time all; | ||
a | ||
5 | ||
update t set a=6; | ||
call truncate_history_of_t(); | ||
select * from t for system_time all; | ||
a | ||
6 | ||
set @ts1 = now(6); | ||
update t set a=7; | ||
set @ts2 = now(6); | ||
update t set a=8; | ||
truncate t for system_time timestamp from '1-1-1' to @ts1; | ||
select * from t for system_time all; | ||
a | ||
8 | ||
7 | ||
update t set a=9; | ||
truncate t for system_time timestamp between '1-1-1' and @ts2; | ||
select * from t for system_time all; | ||
a | ||
9 | ||
8 | ||
drop table t; | ||
drop procedure truncate_history_of_t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include/master-slave.inc | ||
[connection master] | ||
create table t (a int) with system versioning engine=innodb; | ||
truncate t for system_time all; | ||
ERROR HY000: `TRUNCATE FOR SYSTEM_TIME with row-based replication` is not allowed for versioned table | ||
drop table t; | ||
include/rpl_end.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
-- source include/have_innodb.inc | ||
|
||
create table t (a int); | ||
--error ER_VERSIONING_REQUIRED | ||
truncate t for system_time all; | ||
|
||
delimiter ~~; | ||
create procedure truncate_history_of_t() | ||
begin | ||
prepare stmt from 'truncate t for system_time timestamp between \'1-1-1\' and now(6)'; | ||
execute stmt; | ||
drop prepare stmt; | ||
end~~ | ||
delimiter ;~~ | ||
|
||
create or replace table t (a int) with system versioning; | ||
insert into t values (1); | ||
update t set a=2; | ||
select * from t for system_time all; | ||
|
||
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'; | ||
|
||
truncate t for system_time all; | ||
select * from t for system_time all; | ||
|
||
select @test from t; | ||
drop trigger trg_before; | ||
drop trigger trg_after; | ||
|
||
update t set a=3; | ||
update t set a=4; | ||
truncate t for system_time as of timestamp now(6); | ||
select * from t for system_time all; | ||
|
||
truncate t for system_time timestamp between '1-1-1' and now(6); | ||
select * from t for system_time all; | ||
|
||
update t set a=5; | ||
truncate t for system_time timestamp from '1-1-1' to now(6); | ||
select * from t for system_time all; | ||
|
||
update t set a=6; | ||
call truncate_history_of_t(); | ||
select * from t for system_time all; | ||
|
||
set @ts1 = now(6); | ||
update t set a=7; | ||
set @ts2 = now(6); | ||
update t set a=8; | ||
truncate t for system_time timestamp from '1-1-1' to @ts1; | ||
select * from t for system_time all; | ||
update t set a=9; | ||
truncate t for system_time timestamp between '1-1-1' and @ts2; | ||
select * from t for system_time all; | ||
|
||
|
||
create or replace table t (a int) with system versioning engine=innodb; | ||
insert into t values (1); | ||
update t set a=2; | ||
select * from t for system_time all; | ||
|
||
truncate t for system_time all; | ||
select * from t for system_time all; | ||
|
||
update t set a=3; | ||
update t set a=4; | ||
truncate t for system_time as of timestamp now(6); | ||
select * from t for system_time all; | ||
|
||
truncate t for system_time timestamp between '1-1-1' and now(6); | ||
select * from t for system_time all; | ||
|
||
update t set a=5; | ||
truncate t for system_time timestamp from '1-1-1' to now(6); | ||
select * from t for system_time all; | ||
|
||
update t set a=6; | ||
call truncate_history_of_t(); | ||
select * from t for system_time all; | ||
|
||
set @ts1 = now(6); | ||
update t set a=7; | ||
set @ts2 = now(6); | ||
update t set a=8; | ||
truncate t for system_time timestamp from '1-1-1' to @ts1; | ||
select * from t for system_time all; | ||
update t set a=9; | ||
truncate t for system_time timestamp between '1-1-1' and @ts2; | ||
select * from t for system_time all; | ||
|
||
drop table t; | ||
drop procedure truncate_history_of_t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- source include/have_binlog_format_row.inc | ||
-- source include/master-slave.inc | ||
-- source include/have_innodb.inc | ||
|
||
create table t (a int) with system versioning engine=innodb; | ||
--error ER_VERS_NOT_ALLOWED | ||
truncate t for system_time all; | ||
drop table t; | ||
|
||
-- source include/rpl_end.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.