SELECT @i:=@i+1 AS No, trx_id > 0 AS A, begin_ts > '2015-1-1 0:0:0' AS B, commit_ts > begin_ts AS C, concurr_trx IS NULL AS D FROM INFORMATION_SCHEMA.INNODB_VTQ WHERE trx_id > @start_trx_id;
CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=MyISAM;
set @@session.time_zone='+00:00';
CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=MyISAM;
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
INSERT INTO t1(x, y) VALUES
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
set @str2= concat('create table t1', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
set @str2= concat('create table t2', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
insert into t1(x, y) values
(1, 1000),
(1, 1000),
(2, 2000),
(2, 2000),
(3, 3000),
(3, 3000),
...
@@ -872,8 +889,8 @@ INSERT INTO t1(x, y) VALUES
...
@@ -872,8 +889,8 @@ INSERT INTO t1(x, y) VALUES
(7, 7000),
(7, 7000),
(8, 8000),
(8, 8000),
(9, 9000);
(9, 9000);
DELETE FROM t1 WHERE x >= 1;
delete from t1 where x >= 1;
INSERT INTO t1(x, y) VALUES
insert into t1(x, y) values
(1, 1001),
(1, 1001),
(2, 2001),
(2, 2001),
(3, 3001),
(3, 3001),
...
@@ -883,8 +900,13 @@ INSERT INTO t1(x, y) VALUES
...
@@ -883,8 +900,13 @@ INSERT INTO t1(x, y) VALUES
(7, 7001),
(7, 7001),
(8, 8001),
(8, 8001),
(9, 9001);
(9, 9001);
INSERT INTO t2 SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
insert into t2 select x, y from t1 for system_time between timestamp '0000-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
INSERT INTO t1(x, y) VALUES
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
DELETE FROM t1 WHERE x >= 1;
INSERT INTO t1(x, y) VALUES
(1, 1001),
(2, 2001),
(3, 3001),
(4, 4001),
(5, 5001),
(6, 6001),
(7, 7001),
(8, 8001),
(9, 9001);
INSERT INTO t2 SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY(x, y)) WITH SYSTEM VERSIONING;
set @@session.time_zone='+00:00';
INSERT INTO t1(x, y) VALUES
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end),
primary key(x, y))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values
(1, 1000),
(1, 1000),
(2, 2000),
(2, 2000),
(3, 3000),
(3, 3000),
...
@@ -427,11 +444,15 @@ INSERT INTO t1(x, y) VALUES
...
@@ -427,11 +444,15 @@ INSERT INTO t1(x, y) VALUES
(7, 7000),
(7, 7000),
(8, 8000),
(8, 8000),
(9, 9000);
(9, 9000);
INSERT INTO t1(x, y) VALUES(3, 3000) ON DUPLICATE KEY UPDATE y = y+1;
insert into t1(x, y) values(3, 3000) on duplicate key update y = y+1;
INSERT INTO t1(x, y) VALUES(4, 4000) ON DUPLICATE KEY UPDATE y = y+1;
insert into t1(x, y) values(4, 4000) on duplicate key update y = y+1;
INSERT INTO t1(x, y) VALUES(4, 4001) ON DUPLICATE KEY UPDATE y = y+1;
insert into t1(x, y) values(4, 4001) on duplicate key update y = y+1;
INSERT INTO t1(x, y) VALUES(4, 4444) ON DUPLICATE KEY UPDATE y = y+1;
insert into t1(x, y) values(4, 4444) on duplicate key update y = y+1;
SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY(x, y)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
INSERT INTO t1(x, y) VALUES
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
INSERT INTO t1(x, y) VALUES(3, 3000) ON DUPLICATE KEY UPDATE y = y+1;
INSERT INTO t1(x, y) VALUES(4, 4000) ON DUPLICATE KEY UPDATE y = y+1;
INSERT INTO t1(x, y) VALUES(4, 4001) ON DUPLICATE KEY UPDATE y = y+1;
INSERT INTO t1(x, y) VALUES(4, 4444) ON DUPLICATE KEY UPDATE y = y+1;
SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
set @@session.time_zone='+00:00';
CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
INSERT INTO t1(x, y) VALUES
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
set @str2= concat('create table t1', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
set @str2= concat('create table t2', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
insert into t1(x, y) values
(1, 1000),
(1, 1000),
(2, 2000),
(2, 2000),
(3, 3000),
(3, 3000),
...
@@ -1072,7 +1089,7 @@ INSERT INTO t1(x, y) VALUES
...
@@ -1072,7 +1089,7 @@ INSERT INTO t1(x, y) VALUES
(7, 7000),
(7, 7000),
(8, 8000),
(8, 8000),
(9, 9000);
(9, 9000);
INSERT INTO t2(x, y) VALUES
insert into t2(x, y) values
(1, 1010),
(1, 1010),
(2, 2010),
(2, 2010),
(3, 3010),
(3, 3010),
...
@@ -1082,8 +1099,15 @@ INSERT INTO t2(x, y) VALUES
...
@@ -1082,8 +1099,15 @@ INSERT INTO t2(x, y) VALUES
(7, 7010),
(7, 7010),
(8, 8010),
(8, 8010),
(9, 9010);
(9, 9010);
UPDATE t1, t2 SET t1.y = t1.x + t1.y, t2.y = t2.x + t2.y WHERE t1.x > 7 AND t2.x < 7;
update t1, t2 set t1.y = t1.x + t1.y, t2.y = t2.x + t2.y where t1.x > 7 and t2.x < 7;
SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
select x, y from t1;
select x, y from t2 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
INSERT INTO t1(x, y) VALUES
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
INSERT INTO t2(x, y) VALUES
(1, 1010),
(2, 2010),
(3, 3010),
(4, 4010),
(5, 5010),
(6, 6010),
(7, 7010),
(8, 8010),
(9, 9010);
UPDATE t1, t2 SET t1.y = t1.x + t1.y, t2.y = t2.x + t2.y WHERE t1.x > 7 AND t2.x < 7;
SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
x y
x y
1 1000
1 1000
2 2000
2 2000
...
@@ -1173,7 +1169,6 @@ x y
...
@@ -1173,7 +1169,6 @@ x y
9 9009
9 9009
8 8000
8 8000
9 9000
9 9000
SELECT x, y FROM t1;
x y
x y
1 1000
1 1000
2 2000
2 2000
...
@@ -1184,7 +1179,6 @@ x y
...
@@ -1184,7 +1179,6 @@ x y
7 7000
7 7000
8 8008
8 8008
9 9009
9 9009
SELECT x, y FROM t2 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
set @@session.time_zone='+00:00';
INSERT INTO t1(x, y) VALUES
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
INSERT INTO t1(x, y) VALUES
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
SELECT x, y FROM t1;
x y
x y
1 1000
1 1000
2 2000
2 2000
...
@@ -794,8 +802,6 @@ x y
...
@@ -794,8 +802,6 @@ x y
7 7000
7 7000
8 8000
8 8000
9 9000
9 9000
UPDATE t1 SET y = y + 1 WHERE x > 7;
SELECT x, y FROM t1;
x y
x y
1 1000
1 1000
2 2000
2 2000
...
@@ -806,7 +812,6 @@ x y
...
@@ -806,7 +812,6 @@ x y
7 7000
7 7000
8 8001
8 8001
9 9001
9 9001
SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
x y
x y
1 1000
1 1000
2 2000
2 2000
...
@@ -819,9 +824,24 @@ x y
...
@@ -819,9 +824,24 @@ x y
9 9001
9 9001
8 8000
8 8000
9 9000
9 9000
DROP TABLE t1;
drop procedure test_01;
SET @i = 0;
create procedure verify_vtq()
SELECT @i:=@i+1 AS No, trx_id > 0 AS A, begin_ts > '2015-1-1 0:0:0' AS B, commit_ts > begin_ts AS C, concurr_trx IS NULL AS D FROM INFORMATION_SCHEMA.INNODB_VTQ WHERE trx_id > @start_trx_id;