mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +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:
@@ -5,13 +5,6 @@
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
let $non_sys_datatype= `select sys_datatype(non_default_engine())`;
|
||||
let $non_sys_datatype_uc= `select upper(sys_datatype(non_default_engine()))`;
|
||||
let $sys_datatype_null= $sys_datatype NULL DEFAULT NULL;
|
||||
let $sys_datatype_default_null= $sys_datatype DEFAULT NULL;
|
||||
let $sys_datatype_not_null= $sys_datatype NOT NULL DEFAULT '0000-00-00 00:00:00.000000';
|
||||
let $non_sys_datatype_null= $non_sys_datatype NULL;
|
||||
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE NULL ''
|
||||
eval create table t1 (
|
||||
x1 int unsigned,
|
||||
@@ -133,52 +126,52 @@ create or replace table t1 (
|
||||
# columns with/without system versioning
|
||||
|
||||
create or replace table t1 (
|
||||
A1 int with system versioning,
|
||||
x15 int with system versioning,
|
||||
B int
|
||||
);
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
show create table t1;
|
||||
|
||||
create or replace table t1 (
|
||||
A2 int with system versioning,
|
||||
x16 int with system versioning,
|
||||
B int
|
||||
) with system versioning;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
show create table t1;
|
||||
|
||||
create or replace table t1 (
|
||||
A3 int,
|
||||
x17 int,
|
||||
B int without system versioning
|
||||
);
|
||||
|
||||
create or replace table t1 (
|
||||
A4 int,
|
||||
x18 int,
|
||||
B int without system versioning
|
||||
) with system versioning;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
show create table t1;
|
||||
|
||||
create or replace table t1 (
|
||||
A5 int with system versioning,
|
||||
x19 int with system versioning,
|
||||
B int without system versioning
|
||||
);
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
show create table t1;
|
||||
|
||||
create or replace table t1 (
|
||||
A6 int with system versioning,
|
||||
x20 int with system versioning,
|
||||
B int without system versioning
|
||||
) with system versioning;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
show create table t1;
|
||||
|
||||
create or replace table t1 (
|
||||
A7 int without system versioning
|
||||
x21 int without system versioning
|
||||
);
|
||||
|
||||
--error ER_VERS_NO_COLS_DEFINED
|
||||
--error ER_VERS_TABLE_MUST_HAVE_COLUMNS
|
||||
create or replace table t1 (
|
||||
A8 int without system versioning
|
||||
x22 int without system versioning
|
||||
) with system versioning;
|
||||
|
||||
# CREATE TABLE ... LIKE
|
||||
@@ -193,7 +186,7 @@ create temporary table tt1 like t1;
|
||||
show create table tt1;
|
||||
|
||||
--echo # CREATE TABLE ... SELECT
|
||||
create or replace table t1 (x int) with system versioning;
|
||||
create or replace table t1 (x23 int) with system versioning;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
eval create or replace table t0(
|
||||
y int,
|
||||
@@ -247,14 +240,14 @@ show create table t3;
|
||||
select y from t3 where st = @st;
|
||||
|
||||
--echo ### 4. system fields not or wrongly selected
|
||||
create or replace table t3 with system versioning select x from t1;
|
||||
create or replace table t3 with system versioning select x23 from t1;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE $sys_datatype_null SYS_DATATYPE $sys_datatype_not_null SYS_DATATYPE $sys_datatype_default_null SYS_DATATYPE
|
||||
show create table t3;
|
||||
select * from t3;
|
||||
--error ER_MISSING
|
||||
create or replace table t3 with system versioning select x, sys_trx_start from t1;
|
||||
create or replace table t3 with system versioning select x23, sys_trx_start from t1;
|
||||
--error ER_MISSING
|
||||
create or replace table t3 with system versioning select x, sys_trx_end from t1;
|
||||
create or replace table t3 with system versioning select x23, sys_trx_end from t1;
|
||||
|
||||
--echo # Prepare checking for historical row
|
||||
delete from t1;
|
||||
@@ -281,29 +274,34 @@ select st, en from t3 where y = 2 into @st, @en;
|
||||
select y from t2 for system_time all where st = @st and en = @en;
|
||||
|
||||
--echo ## Default engine detection
|
||||
--replace_result $non_default_engine NON_DEFAULT_ENGINE $non_sys_datatype NON_SYS_DATATYPE
|
||||
eval create or replace table t1 (a int) with system versioning engine $non_default_engine;
|
||||
--replace_result $non_default_engine NON_DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
eval create or replace table t1 (x25 int) with system versioning engine $non_default_engine;
|
||||
create or replace table t2
|
||||
as select a, sys_trx_start, sys_trx_end from t1 for system_time all;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $non_sys_datatype NON_SYS_DATATYPE $non_sys_datatype_null NON_SYS_DATATYPE
|
||||
as select x25, sys_trx_start, sys_trx_end from t1 for system_time all;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE $sys_datatype_null SYS_DATATYPE
|
||||
show create table t2;
|
||||
|
||||
create or replace table t2 with system versioning
|
||||
as select a, sys_trx_start, sys_trx_end from t1;
|
||||
--replace_result $non_default_engine NON_DEFAULT_ENGINE $non_sys_datatype NON_SYS_DATATYPE
|
||||
as select x25, sys_trx_start, sys_trx_end from t1;
|
||||
--replace_result $non_default_engine NON_DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
show create table t2;
|
||||
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype_uc SYS_DATATYPE
|
||||
create or replace table t1 (
|
||||
x26 int,
|
||||
st bigint unsigned generated always as row start,
|
||||
en bigint unsigned generated always as row end,
|
||||
period for system_time (st, en)
|
||||
) with system versioning engine innodb;
|
||||
--error ER_VERS_FIELD_WRONG_TYPE
|
||||
eval create or replace table t2 with system versioning engine $default_engine
|
||||
as select a, sys_trx_start, sys_trx_end from t1 for system_time all;
|
||||
create or replace table t2 with system versioning engine myisam
|
||||
as select * from t1;
|
||||
|
||||
--replace_result $non_default_engine NON_DEFAULT_ENGINE
|
||||
eval create or replace table t1 (a int, id int) with system versioning engine $non_default_engine;
|
||||
eval create or replace table t1 (x27 int, id int) with system versioning engine $non_default_engine;
|
||||
create or replace table t2 (b int, id int);
|
||||
create or replace table t3 with system versioning
|
||||
as select t2.b, t1.a, t1.sys_trx_start, t1.sys_trx_end from t2 inner join t1 on t2.id=t1.id;
|
||||
--replace_result $non_default_engine NON_DEFAULT_ENGINE $non_sys_datatype NON_SYS_DATATYPE $non_sys_datatype_null NON_SYS_DATATYPE
|
||||
as select t2.b, t1.x27, t1.sys_trx_start, t1.sys_trx_end from t2 inner join t1 on t2.id=t1.id;
|
||||
--replace_result $non_default_engine NON_DEFAULT_ENGINE $sys_datatype SYS_DATATYPE $sys_datatype_null SYS_DATATYPE
|
||||
show create table t3;
|
||||
|
||||
--echo ## Errors
|
||||
@@ -316,11 +314,11 @@ create or replace table t (sys_trx_end int);
|
||||
alter table t with system versioning;
|
||||
|
||||
--error ER_WRONG_USAGE
|
||||
create or replace temporary table t (x int) with system versioning;
|
||||
create or replace temporary table t (x28 int) with system versioning;
|
||||
|
||||
--error ER_VERS_DUPLICATE_ROW_START_END
|
||||
create or replace table t1 (
|
||||
x11 int unsigned,
|
||||
x29 int unsigned,
|
||||
Sys_start0 timestamp(6) generated always as row start,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
@@ -328,7 +326,7 @@ create or replace table t1 (
|
||||
) with system versioning;
|
||||
|
||||
--echo ## System fields detection
|
||||
create or replace table t1 (x int) with system versioning;
|
||||
create or replace table t1 (x30 int) with system versioning;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
eval create or replace table t2 (
|
||||
y int,
|
||||
@@ -338,7 +336,7 @@ eval create or replace table t2 (
|
||||
) with system versioning;
|
||||
|
||||
create or replace table t3
|
||||
as select x, y, sys_trx_start, sys_trx_end, st, en from t1, t2;
|
||||
as select x30, y, sys_trx_start, sys_trx_end, st, en from t1, t2;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE $sys_datatype_null SYS_DATATYPE $sys_datatype_not_null SYS_DATATYPE $sys_datatype_default_null SYS_DATATYPE
|
||||
show create table t3;
|
||||
|
||||
@@ -349,7 +347,7 @@ eval create or replace table t3 (
|
||||
en $sys_datatype generated always as row end,
|
||||
period for system_time (st, en)
|
||||
) with system versioning
|
||||
as select x, y, sys_trx_start, sys_trx_end, st, en from t1, t2;
|
||||
as select x30, y, sys_trx_start, sys_trx_end, st, en from t1, t2;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE $sys_datatype_null SYS_DATATYPE $sys_datatype_not_null SYS_DATATYPE $sys_datatype_default_null SYS_DATATYPE
|
||||
show create table t3;
|
||||
|
||||
|
Reference in New Issue
Block a user