1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

Timestamp-based versioning for InnoDB [closes #209]

* Removed integer_fields check
* Reworked Vers_parse_info::check_sys_fields()
* Misc renames
* versioned as vers_sys_type_t

* Removed versioned_by_sql(), versioned_by_engine()

versioned() works as before;
versioned(VERS_TIMESTAMP) is versioned_by_sql();
versioned(VERS_TRX_ID) is versioned_by_engine().

* create_tmp_table() fix
* Foreign constraints for timestamp-based
* Range auto-specifier fix
* SQL: 1-row partition rotation fix [fixes #260]
* Fix 'drop system versioning, algorithm=inplace'
This commit is contained in:
Aleksey Midenkov
2017-12-18 19:03:51 +03:00
committed by GitHub
parent d5e37621cf
commit b55a149194
73 changed files with 1178 additions and 836 deletions

View File

@@ -7,9 +7,9 @@ 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))
sys_trx_start ', sys_type, ' generated always as row start,
sys_trx_end ', sys_type, ' generated always as row end,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
@@ -40,7 +40,10 @@ set @str= concat('
create table t1 (
id bigint primary key,
x int,
y int without system versioning)
y int without system versioning,
sys_trx_start ', sys_type, ' as row start,
sys_trx_end ', sys_type, ' as row end,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
@@ -62,8 +65,11 @@ begin
set @str= concat('
create table t1 (
x int,
y int)
with system versioning
y int,
sys_trx_start bigint unsigned as row start,
sys_trx_end bigint unsigned as row end,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1 (x, y) values (1, 1), (2, 1), (3, 1), (4, 1), (5, 1);
@@ -85,7 +91,10 @@ begin
set @str= concat('
create table t1 (
id int primary key auto_increment,
x int)
x int,
sys_trx_start ', sys_type, ' as row start,
sys_trx_end ', sys_type, ' as row end,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
@@ -109,10 +118,10 @@ begin
set @str= concat('
create table t1(
x int unsigned,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' generated always as row start,
sys_trx_end ', sys_type, ' generated always as row end,
sys_trx_start ', sys_type, ' generated always as row start,
y int unsigned,
period for system_time (sys_start, sys_end),
period for system_time (sys_trx_start, sys_trx_end),
primary key(x, y))
with system versioning
engine ', engine);
@@ -136,9 +145,9 @@ 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))
sys_trx_start ', sys_type, ' generated always as row start,
sys_trx_end ', sys_type, ' generated always as row end,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
set @str2= concat('create table t1', @str);
@@ -179,9 +188,13 @@ engine varchar(255),
fields varchar(255))
begin
set @str= concat('(
id bigint primary key,
name varchar(128) with system versioning,
salary bigint)
id bigint primary key without system versioning,
name varchar(128),
salary bigint without system versioning,
sys_trx_start ', sys_type, ' as row start,
sys_trx_end ', sys_type, ' as row end,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
set @str2= concat('create table t1', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
@@ -202,7 +215,7 @@ select @tmp2 = sys_trx_start as B2, salary from t2;
drop table t1;
drop table t2;
end~~
call test_01('timestamp(6)', 'myisam', 'sys_end');
call test_01('timestamp(6)', 'myisam', 'sys_trx_end');
x y
1 1000
2 2000
@@ -235,7 +248,40 @@ x y
9 9001
8 8000
9 9000
call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
call test_01('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8000
9 9000
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8001
9 9001
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8001
9 9001
8 8000
9 9000
call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x y
1 1000
2 2000
@@ -272,12 +318,17 @@ call verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
call test_02('timestamp(6)', 'myisam', 'sys_end');
call test_02('timestamp(6)', 'myisam', 'sys_trx_end');
A1 x y
1 11 11
A2 x
1 11
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
call test_02('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_end)');
A1 x y
1 11 11
A2 x
1 11
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
A1 x y
1 11 11
A2 x
@@ -287,8 +338,8 @@ No A B C D
1 1 1 1 1
2 1 1 1 1
# Multiple UPDATE of same rows in single transaction create historical
# rows only once (applicable to InnoDB only).
call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
# rows only once (applicable to transaction-based only).
call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x y current
1 1 1
2 2 1
@@ -303,7 +354,7 @@ call verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
call test_04('timestamp(6)', 'myisam', 'sys_end');
call test_04('timestamp(6)', 'myisam', 'sys_trx_end');
x
x
1
@@ -311,7 +362,15 @@ x
2
x
3
call test_04('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
call test_04('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x
x
1
x
2
x
3
call test_04('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x
x
1
@@ -324,7 +383,7 @@ No A B C D
1 1 1 1 1
2 1 1 1 1
3 1 1 1 1
call test_05('timestamp(6)', 'myisam', 'sys_end');
call test_05('timestamp(6)', 'myisam', 'sys_trx_end');
x y
1 1000
3 3000
@@ -338,7 +397,21 @@ x y
4 4000
4 4444
5 5000
call test_05('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
call test_05('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x y
1 1000
3 3000
3 3001
4 4000
4 4444
5 5000
x y
1 1000
3 3001
4 4000
4 4444
5 5000
call test_05('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x y
1 1000
3 3000
@@ -357,7 +430,7 @@ No A B C D
1 1 1 1 1
2 1 1 1 1
3 1 1 1 1
call test_06('timestamp(6)', 'myisam', 'sys_end');
call test_06('timestamp(6)', 'myisam', 'sys_trx_end');
x y
1 1000
2 2000
@@ -406,7 +479,56 @@ x y
7 7010
8 8010
9 9010
call test_06('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
call test_06('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8008
9 9009
8 8000
9 9000
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8008
9 9009
x y
1 1011
2 2012
3 3013
4 4014
5 5015
6 6016
7 7010
8 8010
9 9010
1 1010
2 2010
3 3010
4 4010
5 5010
6 6010
x y
1 1011
2 2012
3 3013
4 4014
5 5015
6 6016
7 7010
8 8010
9 9010
call test_06('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x y
1 1000
2 2000
@@ -460,7 +582,8 @@ No A B C D
1 1 1 1 1
2 1 1 1 1
3 1 1 1 1
call test_07('timestamp(6)', 'myisam', 'sys_end');
# Optimized fields
call test_07('timestamp(6)', 'myisam', 'sys_trx_end');
A1 name
1 Jerry
A2 name
@@ -469,7 +592,16 @@ B1 salary
1 2500
B2 salary
1 2500
call test_07('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
call test_07('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_end)');
A1 name
1 Jerry
A2 name
1 Jerry
B1 salary
1 2500
B2 salary
1 2500
call test_07('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
A1 name
1 Jerry
A2 name