Commit 66849898 authored by Aleksey Midenkov's avatar Aleksey Midenkov

versioning test suite fixes

Preparation for MDEV-16210:

replace.test:
key_type combinations: PK and UNIQUE.

foreign.test:
Preparation for key_type combinations.

Other fixes:

* Merged versioning.update2 into versioning.update;
* Removed test2 database and done individual drop instead.
parent cf71cc83
...@@ -4,14 +4,14 @@ row_start SYS_TYPE as row start invisible, ...@@ -4,14 +4,14 @@ row_start SYS_TYPE as row start invisible,
row_end SYS_TYPE as row end invisible, row_end SYS_TYPE as row end invisible,
period for system_time (row_start, row_end)) period for system_time (row_start, row_end))
with system versioning; with system versioning;
create or replace table tf engine=FEDERATED connection='mysql://root@127.0.0.1:MASTER_MYPORT/test2/t1'; create or replace table tf engine=FEDERATED connection='mysql://root@127.0.0.1:MASTER_MYPORT/test/t1';
show create table tf; show create table tf;
Table Create Table Table Create Table
tf CREATE TABLE `tf` ( tf CREATE TABLE `tf` (
`x` int(11) DEFAULT NULL, `x` int(11) DEFAULT NULL,
`row_start` SYS_TYPE NOT NULL INVISIBLE DEFAULT 0, `row_start` SYS_TYPE NOT NULL INVISIBLE DEFAULT 0,
`row_end` SYS_TYPE NOT NULL INVISIBLE DEFAULT 0 `row_end` SYS_TYPE NOT NULL INVISIBLE DEFAULT 0
) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:MASTER_MYPORT/test2/t1' ) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:MASTER_MYPORT/test/t1'
# INSERT # INSERT
insert into t1 values (1); insert into t1 values (1);
select * from tf; select * from tf;
...@@ -57,7 +57,7 @@ row_start SYS_TYPE as row start invisible, ...@@ -57,7 +57,7 @@ row_start SYS_TYPE as row start invisible,
row_end SYS_TYPE as row end invisible, row_end SYS_TYPE as row end invisible,
period for system_time (row_start, row_end)) period for system_time (row_start, row_end))
with system versioning; with system versioning;
create or replace table t2f engine=FEDERATED connection='mysql://root@127.0.0.1:MASTER_MYPORT/test2/t2'; create or replace table t2f engine=FEDERATED connection='mysql://root@127.0.0.1:MASTER_MYPORT/test/t2';
insert t2f (id, y) values (1, 2); insert t2f (id, y) values (1, 2);
replace t2f (id, y) values (1, 3); replace t2f (id, y) values (1, 3);
select *, check_row(row_start, row_end) from t2 for system_time all select *, check_row(row_start, row_end) from t2 for system_time all
...@@ -96,3 +96,5 @@ order by y; ...@@ -96,3 +96,5 @@ order by y;
id y check_row(row_start, row_end) id y check_row(row_start, row_end)
2 2 HISTORICAL ROW 2 2 HISTORICAL ROW
2 22 CURRENT ROW 2 22 CURRENT ROW
drop view vt1;
drop tables t1, t2, t2f, tf;
...@@ -11,7 +11,7 @@ eval create or replace table t1 ( ...@@ -11,7 +11,7 @@ eval create or replace table t1 (
period for system_time (row_start, row_end)) period for system_time (row_start, row_end))
with system versioning; with system versioning;
--replace_result $MASTER_MYPORT MASTER_MYPORT --replace_result $MASTER_MYPORT MASTER_MYPORT
eval create or replace table tf engine=FEDERATED connection='mysql://root@127.0.0.1:$MASTER_MYPORT/test2/t1'; eval create or replace table tf engine=FEDERATED connection='mysql://root@127.0.0.1:$MASTER_MYPORT/test/t1';
--replace_result $MASTER_MYPORT MASTER_MYPORT $sys_datatype_expl SYS_TYPE "'0000-00-00 00:00:00.000000'" 0 --replace_result $MASTER_MYPORT MASTER_MYPORT $sys_datatype_expl SYS_TYPE "'0000-00-00 00:00:00.000000'" 0
show create table tf; show create table tf;
--echo # INSERT --echo # INSERT
...@@ -45,7 +45,7 @@ eval create or replace table t2 ( ...@@ -45,7 +45,7 @@ eval create or replace table t2 (
period for system_time (row_start, row_end)) period for system_time (row_start, row_end))
with system versioning; with system versioning;
--replace_result $MASTER_MYPORT MASTER_MYPORT --replace_result $MASTER_MYPORT MASTER_MYPORT
eval create or replace table t2f engine=FEDERATED connection='mysql://root@127.0.0.1:$MASTER_MYPORT/test2/t2'; eval create or replace table t2f engine=FEDERATED connection='mysql://root@127.0.0.1:$MASTER_MYPORT/test/t2';
insert t2f (id, y) values (1, 2); insert t2f (id, y) values (1, 2);
replace t2f (id, y) values (1, 3); replace t2f (id, y) values (1, 3);
select *, check_row(row_start, row_end) from t2 for system_time all select *, check_row(row_start, row_end) from t2 for system_time all
...@@ -72,4 +72,7 @@ order by x; ...@@ -72,4 +72,7 @@ order by x;
select *, check_row(row_start, row_end) from t2 for system_time all select *, check_row(row_start, row_end) from t2 for system_time all
order by y; order by y;
drop view vt1;
drop tables t1, t2, t2f, tf;
--source suite/versioning/common_finish.inc --source suite/versioning/common_finish.inc
...@@ -4,8 +4,6 @@ if (!$TEST_VERSIONING_SO) ...@@ -4,8 +4,6 @@ if (!$TEST_VERSIONING_SO)
--skip needs test_versioning plugin --skip needs test_versioning plugin
} }
source include/have_innodb.inc; source include/have_innodb.inc;
create database test2 character set latin1;
use test2;
set @@session.time_zone='+00:00'; set @@session.time_zone='+00:00';
select ifnull(max(transaction_id), 0) into @start_trx_id from mysql.transaction_registry; select ifnull(max(transaction_id), 0) into @start_trx_id from mysql.transaction_registry;
......
...@@ -5,7 +5,4 @@ drop procedure if exists verify_trt_dummy; ...@@ -5,7 +5,4 @@ drop procedure if exists verify_trt_dummy;
drop function if exists current_row; drop function if exists current_row;
drop function if exists check_row; drop function if exists check_row;
--enable_warnings --enable_warnings
use test;
drop database test2;
--enable_query_log --enable_query_log
--disable_query_log
if ($MTR_COMBINATION_UNIQUE)
{
let $KEY_TYPE= unique;
}
if ($MTR_COMBINATION_PK)
{
let $KEY_TYPE= primary key;
}
if ($MTR_COMBINATION_SEC)
{
let $KEY_TYPE= key;
}
--enable_query_log
...@@ -18,13 +18,13 @@ t CREATE TABLE `t` ( ...@@ -18,13 +18,13 @@ t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL `a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column y int; alter table t add column y int;
ERROR HY000: Not allowed for system-versioned `test2`.`t`. Change @@system_versioning_alter_history to proceed with ALTER. ERROR HY000: Not allowed for system-versioned `test`.`t`. Change @@system_versioning_alter_history to proceed with ALTER.
alter table t add primary key (a); alter table t add primary key (a);
ERROR HY000: Not allowed for system-versioned `test2`.`t`. Change @@system_versioning_alter_history to proceed with ALTER. ERROR HY000: Not allowed for system-versioned `test`.`t`. Change @@system_versioning_alter_history to proceed with ALTER.
alter table t add unique key (a); alter table t add unique key (a);
ERROR HY000: Not allowed for system-versioned `test2`.`t`. Change @@system_versioning_alter_history to proceed with ALTER. ERROR HY000: Not allowed for system-versioned `test`.`t`. Change @@system_versioning_alter_history to proceed with ALTER.
alter table t engine innodb; alter table t engine innodb;
ERROR HY000: Not allowed for system-versioned `test2`.`t`. Change to/from native system versioning engine is not supported. ERROR HY000: Not allowed for system-versioned `test`.`t`. Change to/from native system versioning engine is not supported.
alter table t drop system versioning; alter table t drop system versioning;
show create table t; show create table t;
Table Create Table Table Create Table
...@@ -527,7 +527,7 @@ create or replace table t (x int) with system versioning; ...@@ -527,7 +527,7 @@ create or replace table t (x int) with system versioning;
ERROR HY000: System versioning tables in the `mysql` database are not suported ERROR HY000: System versioning tables in the `mysql` database are not suported
alter table user add system versioning; alter table user add system versioning;
ERROR HY000: System versioning tables in the `mysql` database are not suported ERROR HY000: System versioning tables in the `mysql` database are not suported
use test2; use test;
# MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column # MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column
create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning; create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning;
alter table t1 modify s timestamp(6) as row start; alter table t1 modify s timestamp(6) as row start;
...@@ -537,10 +537,10 @@ create or replace table t (a int) with system versioning; ...@@ -537,10 +537,10 @@ create or replace table t (a int) with system versioning;
insert into t values (0), (1); insert into t values (0), (1);
delete from t where a = 0; delete from t where a = 0;
alter table t add check (a > 1); alter table t add check (a > 1);
ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test2`.`t` ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t`
alter table t add check (a > 0); alter table t add check (a > 0);
insert into t values (0); insert into t values (0);
ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test2`.`t` ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t`
insert into t values (2); insert into t values (2);
# #
# MDEV-18869 Assertion `!((field)->vcol_info && (field)->stored_in_db())' failed in innodb_col_no upon altering table with system versioning # MDEV-18869 Assertion `!((field)->vcol_info && (field)->stored_in_db())' failed in innodb_col_no upon altering table with system versioning
...@@ -679,5 +679,4 @@ alter table t ...@@ -679,5 +679,4 @@ alter table t
add column c int without system versioning, add column c int without system versioning,
change column c c int, change column c c int,
change column b b int without system versioning; change column b b int without system versioning;
drop database test; drop table t;
create database test;
...@@ -15,7 +15,7 @@ t1 CREATE TABLE `t1` ( ...@@ -15,7 +15,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select table_catalog,table_schema,table_name,table_type,version,table_rows,data_free,auto_increment,check_time,table_collation,checksum,create_options,table_comment from information_schema.tables where table_name='t1'; select table_catalog,table_schema,table_name,table_type,version,table_rows,data_free,auto_increment,check_time,table_collation,checksum,create_options,table_comment from information_schema.tables where table_name='t1';
table_catalog def table_catalog def
table_schema test2 table_schema test
table_name t1 table_name t1
table_type SYSTEM VERSIONED table_type SYSTEM VERSIONED
version 10 version 10
...@@ -29,7 +29,7 @@ create_options ...@@ -29,7 +29,7 @@ create_options
table_comment table_comment
select table_catalog,table_schema,table_name,column_name,ordinal_position,column_default,character_maximum_length,character_octet_length,character_set_name,collation_name,column_key,extra,column_comment,is_generated,generation_expression from information_schema.columns where table_name='t1'; select table_catalog,table_schema,table_name,column_name,ordinal_position,column_default,character_maximum_length,character_octet_length,character_set_name,collation_name,column_key,extra,column_comment,is_generated,generation_expression from information_schema.columns where table_name='t1';
table_catalog def table_catalog def
table_schema test2 table_schema test
table_name t1 table_name t1
column_name x1 column_name x1
ordinal_position 1 ordinal_position 1
...@@ -44,7 +44,7 @@ column_comment ...@@ -44,7 +44,7 @@ column_comment
is_generated NEVER is_generated NEVER
generation_expression NULL generation_expression NULL
table_catalog def table_catalog def
table_schema test2 table_schema test
table_name t1 table_name t1
column_name Sys_start column_name Sys_start
ordinal_position 2 ordinal_position 2
...@@ -59,7 +59,7 @@ column_comment start ...@@ -59,7 +59,7 @@ column_comment start
is_generated ALWAYS is_generated ALWAYS
generation_expression ROW START generation_expression ROW START
table_catalog def table_catalog def
table_schema test2 table_schema test
table_name t1 table_name t1
column_name Sys_end column_name Sys_end
ordinal_position 3 ordinal_position 3
...@@ -235,7 +235,7 @@ tt1 CREATE TABLE `tt1` ( ...@@ -235,7 +235,7 @@ tt1 CREATE TABLE `tt1` (
drop table tt1; drop table tt1;
create temporary table tt1 like t1; create temporary table tt1 like t1;
Warnings: Warnings:
Warning 1105 System versioning is stripped from temporary `test2.tt1` Warning 1105 System versioning is stripped from temporary `test.tt1`
# Temporary is stripped from versioning # Temporary is stripped from versioning
show create table tt1; show create table tt1;
Table Create Table Table Create Table
...@@ -523,5 +523,4 @@ create or replace table t1 (x int without system versioning) ...@@ -523,5 +523,4 @@ create or replace table t1 (x int without system versioning)
with system versioning with system versioning
select 1 as x; select 1 as x;
ERROR HY000: Table `t1` must have at least one versioned column ERROR HY000: Table `t1` must have at least one versioned column
drop database test; drop tables t0, t1, t2, t3;
create database test;
...@@ -115,3 +115,4 @@ select x from t1 for system_time all; ...@@ -115,3 +115,4 @@ select x from t1 for system_time all;
x x
2 2
1 1
drop table t1;
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
# Test RESTRICT # # Test RESTRICT #
################# #################
create table parent( create table parent(
id int unique key id int,
KEY_TYPE (id)
) engine innodb; ) engine innodb;
create table child( create table child(
parent_id int, parent_id int,
...@@ -16,13 +17,13 @@ on update restrict ...@@ -16,13 +17,13 @@ on update restrict
insert into parent values(1); insert into parent values(1);
insert into child values(1); insert into child values(1);
delete from parent where id = 1; delete from parent where id = 1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test2`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
delete from child where parent_id = 1; delete from child where parent_id = 1;
delete from parent where id = 1; delete from parent where id = 1;
insert into parent values(1); insert into parent values(1);
insert into child values(1); insert into child values(1);
update parent set id=id+1; update parent set id=id+1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test2`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
delete from child; delete from child;
update parent set id=id+1; update parent set id=id+1;
select * from child for system_time all; select * from child for system_time all;
...@@ -35,7 +36,8 @@ drop table parent; ...@@ -35,7 +36,8 @@ drop table parent;
# Test when clustered index is a foreign key # # Test when clustered index is a foreign key #
############################################## ##############################################
create table parent( create table parent(
id int(10) unsigned unique key id int(10) unsigned,
KEY_TYPE (id)
) engine innodb; ) engine innodb;
create table child( create table child(
parent_id int(10) unsigned primary key, parent_id int(10) unsigned primary key,
...@@ -47,14 +49,15 @@ foreign key(parent_id) references parent(id) ...@@ -47,14 +49,15 @@ foreign key(parent_id) references parent(id)
insert into parent values(1); insert into parent values(1);
insert into child values(1); insert into child values(1);
delete from parent where id = 1; delete from parent where id = 1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test2`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
drop table child; drop table child;
drop table parent; drop table parent;
################ ################
# Test CASCADE # # Test CASCADE #
################ ################
create table parent( create table parent(
id int unique key id int,
KEY_TYPE (id)
) engine innodb; ) engine innodb;
create table child( create table child(
parent_id int, parent_id int,
...@@ -87,7 +90,8 @@ parent_id ...@@ -87,7 +90,8 @@ parent_id
drop table child; drop table child;
drop table parent; drop table parent;
create or replace table parent ( create or replace table parent (
id int primary key, id int,
KEY_TYPE(id),
sys_start SYS_DATATYPE as row start invisible, sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible, sys_end SYS_DATATYPE as row end invisible,
period for system_time(sys_start, sys_end) period for system_time(sys_start, sys_end)
...@@ -110,7 +114,8 @@ x parent_id ...@@ -110,7 +114,8 @@ x parent_id
drop table child; drop table child;
drop table parent; drop table parent;
create or replace table parent ( create or replace table parent (
id int primary key id int,
KEY_TYPE(id)
) )
engine innodb; engine innodb;
create or replace table child ( create or replace table child (
...@@ -138,8 +143,9 @@ drop table parent; ...@@ -138,8 +143,9 @@ drop table parent;
################# #################
# Test SET NULL # # Test SET NULL #
################# #################
create or replace table parent( create table parent(
id int unique key id int,
KEY_TYPE (id)
) engine innodb; ) engine innodb;
create or replace table child( create or replace table child(
parent_id int, parent_id int,
...@@ -183,7 +189,8 @@ drop table parent; ...@@ -183,7 +189,8 @@ drop table parent;
# Parent table is foreign # # Parent table is foreign #
########################### ###########################
create or replace table parent( create or replace table parent(
id int unique key, id int,
KEY_TYPE (id),
sys_start SYS_DATATYPE as row start invisible, sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible, sys_end SYS_DATATYPE as row end invisible,
period for system_time(sys_start, sys_end) period for system_time(sys_start, sys_end)
...@@ -195,26 +202,27 @@ foreign key(parent_id) references parent(id) ...@@ -195,26 +202,27 @@ foreign key(parent_id) references parent(id)
insert into parent values(1); insert into parent values(1);
insert into child values(1); insert into child values(1);
delete from parent; delete from parent;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test2`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
update parent set id=2; update parent set id=2;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test2`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
delete from child; delete from child;
delete from parent; delete from parent;
insert into child values(1); insert into child values(1);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test2`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
insert into parent values(1); insert into parent values(1);
insert into child values(1); insert into child values(1);
delete from parent; delete from parent;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test2`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
update parent set id=2; update parent set id=2;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test2`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
drop table child; drop table child;
drop table parent; drop table parent;
################### ###################
# crash on DELETE # # crash on DELETE #
################### ###################
create or replace table a ( create or replace table a (
cola int(10) primary key, cola int(10),
KEY_TYPE (cola),
v_cola int(10) as (cola mod 10) virtual, v_cola int(10) as (cola mod 10) virtual,
sys_start SYS_DATATYPE as row start invisible, sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible, sys_end SYS_DATATYPE as row end invisible,
...@@ -233,7 +241,7 @@ foreign key (v_cola) references a (v_cola); ...@@ -233,7 +241,7 @@ foreign key (v_cola) references a (v_cola);
insert into a(cola) values (12); insert into a(cola) values (12);
insert into b(cola, v_cola) values (10,2); insert into b(cola, v_cola) values (10,2);
delete from a; delete from a;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test2`.`b`, CONSTRAINT `v_cola_fk` FOREIGN KEY (`v_cola`) REFERENCES `a` (`v_cola`)) ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`b`, CONSTRAINT `v_cola_fk` FOREIGN KEY (`v_cola`) REFERENCES `a` (`v_cola`))
drop table b, a; drop table b, a;
############################################### ###############################################
# CASCADE UPDATE foreign not system versioned # # CASCADE UPDATE foreign not system versioned #
...@@ -296,7 +304,7 @@ SET FOREIGN_KEY_CHECKS= OFF; ...@@ -296,7 +304,7 @@ SET FOREIGN_KEY_CHECKS= OFF;
INSERT IGNORE INTO t2 VALUES (1); INSERT IGNORE INTO t2 VALUES (1);
SET FOREIGN_KEY_CHECKS= ON; SET FOREIGN_KEY_CHECKS= ON;
UPDATE t2 SET f2= 2; UPDATE t2 SET f2= 2;
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test2`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`)) ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`))
DELETE FROM t2; DELETE FROM t2;
DROP TABLE t2, t1; DROP TABLE t2, t1;
# #
......
...@@ -89,13 +89,13 @@ period for system_time(row_start, row_end) ...@@ -89,13 +89,13 @@ period for system_time(row_start, row_end)
insert into t values (1, 1); insert into t values (1, 1);
select c.prtype from information_schema.innodb_sys_columns as c select c.prtype from information_schema.innodb_sys_columns as c
join information_schema.innodb_sys_tables as t on c.table_id=t.table_id join information_schema.innodb_sys_tables as t on c.table_id=t.table_id
where t.name='test2/t' and c.name='b'; where t.name='test/t' and c.name='b';
prtype prtype
50179 50179
set @@system_versioning_alter_history=keep; set @@system_versioning_alter_history=keep;
select c.prtype from information_schema.innodb_sys_columns as c select c.prtype from information_schema.innodb_sys_columns as c
join information_schema.innodb_sys_tables as t on c.table_id=t.table_id join information_schema.innodb_sys_tables as t on c.table_id=t.table_id
where t.name='test2/t' and c.name='b'; where t.name='test/t' and c.name='b';
prtype prtype
50179 50179
show create table t; show create table t;
......
...@@ -46,7 +46,7 @@ period for system_time(row_start, row_end)) ...@@ -46,7 +46,7 @@ period for system_time(row_start, row_end))
engine=DEFAULT_ENGINE engine=DEFAULT_ENGINE
with system versioning partition by hash(i); with system versioning partition by hash(i);
alter table t1 engine=NON_DEFAULT_ENGINE; alter table t1 engine=NON_DEFAULT_ENGINE;
ERROR HY000: Not allowed for system-versioned `test2`.`t1`. Change to/from native system versioning engine is not supported. ERROR HY000: Not allowed for system-versioned `test`.`t1`. Change to/from native system versioning engine is not supported.
## CREATE TABLE ## CREATE TABLE
create or replace table t1 (x int) create or replace table t1 (x int)
partition by system_time ( partition by system_time (
...@@ -254,11 +254,11 @@ x ...@@ -254,11 +254,11 @@ x
6 6
insert into t1 values (7), (8); insert into t1 values (7), (8);
Warnings: Warnings:
Warning 4114 Versioned table `test2`.`t1`: partition `p1` is full, add more HISTORY partitions Warning 4114 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
### warn about full partition ### warn about full partition
delete from t1; delete from t1;
Warnings: Warnings:
Warning 4114 Versioned table `test2`.`t1`: partition `p1` is full, add more HISTORY partitions Warning 4114 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
select * from t1 partition (p1) order by x; select * from t1 partition (p1) order by x;
x x
4 4
...@@ -433,16 +433,16 @@ create or replace table t1 (i int) with system versioning ...@@ -433,16 +433,16 @@ create or replace table t1 (i int) with system versioning
partition by system_time interval 1 hour ( partition by system_time interval 1 hour (
partition p0 history, partition pn current); partition p0 history, partition pn current);
set @ts=(select partition_description from information_schema.partitions set @ts=(select partition_description from information_schema.partitions
where table_schema='test2' and table_name='t1' and partition_name='p0'); where table_schema='test' and table_name='t1' and partition_name='p0');
alter table t1 add column b int; alter table t1 add column b int;
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test2' and table_name='t1'; select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts) partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
p0 1 SYSTEM_TIME 00:00:00.000000 p0 1 SYSTEM_TIME 00:00:00.000000
pn 2 SYSTEM_TIME NULL pn 2 SYSTEM_TIME NULL
Warnings: Warnings:
Warning 1292 Truncated incorrect time value: 'CURRENT' Warning 1292 Truncated incorrect time value: 'CURRENT'
alter table t1 add partition (partition p1 history, partition p2 history); alter table t1 add partition (partition p1 history, partition p2 history);
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test2' and table_name='t1'; select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts) partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
p0 1 SYSTEM_TIME 00:00:00.000000 p0 1 SYSTEM_TIME 00:00:00.000000
p1 2 SYSTEM_TIME 01:00:00.000000 p1 2 SYSTEM_TIME 01:00:00.000000
...@@ -451,7 +451,7 @@ pn 4 SYSTEM_TIME NULL ...@@ -451,7 +451,7 @@ pn 4 SYSTEM_TIME NULL
Warnings: Warnings:
Warning 1292 Truncated incorrect time value: 'CURRENT' Warning 1292 Truncated incorrect time value: 'CURRENT'
alter table t1 drop partition p0; alter table t1 drop partition p0;
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test2' and table_name='t1'; select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts) partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
p1 1 SYSTEM_TIME 01:00:00.000000 p1 1 SYSTEM_TIME 01:00:00.000000
p2 2 SYSTEM_TIME 02:00:00.000000 p2 2 SYSTEM_TIME 02:00:00.000000
...@@ -460,7 +460,7 @@ Warnings: ...@@ -460,7 +460,7 @@ Warnings:
Warning 1292 Truncated incorrect time value: 'CURRENT' Warning 1292 Truncated incorrect time value: 'CURRENT'
alter table t1 drop partition p2; alter table t1 drop partition p2;
ERROR HY000: Can only drop oldest partitions when rotating by INTERVAL ERROR HY000: Can only drop oldest partitions when rotating by INTERVAL
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test2' and table_name='t1'; select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts) partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
p1 1 SYSTEM_TIME 01:00:00.000000 p1 1 SYSTEM_TIME 01:00:00.000000
p2 2 SYSTEM_TIME 02:00:00.000000 p2 2 SYSTEM_TIME 02:00:00.000000
...@@ -556,7 +556,7 @@ insert into t1 values (0), (1), (2), (3); ...@@ -556,7 +556,7 @@ insert into t1 values (0), (1), (2), (3);
delete from t1 where x < 3; delete from t1 where x < 3;
delete from t1; delete from t1;
Warnings: Warnings:
Warning 4114 Versioned table `test2`.`t1`: partition `p1` is full, add more HISTORY partitions Warning 4114 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
unlock tables; unlock tables;
# #
# MDEV-20336 Assertion bitmap_is_set(read_partitions) upon SELECT FOR UPDATE from versioned table # MDEV-20336 Assertion bitmap_is_set(read_partitions) upon SELECT FOR UPDATE from versioned table
...@@ -564,4 +564,5 @@ unlock tables; ...@@ -564,4 +564,5 @@ unlock tables;
create or replace table t1 (pk int primary key) with system versioning partition by system_time limit 100 (partition p1 history, partition pn current); create or replace table t1 (pk int primary key) with system versioning partition by system_time limit 100 (partition p1 history, partition pn current);
execute immediate 'select * from t1 for update'; execute immediate 'select * from t1 for update';
pk pk
drop table t1; drop view v1;
drop tables t, t1, t2, t3, t4;
...@@ -21,6 +21,7 @@ partition p0 history, ...@@ -21,6 +21,7 @@ partition p0 history,
partition pn current partition pn current
); );
ERROR HY000: `row_start` must be of type TIMESTAMP(6) for system-versioned table `#sql-temporary` ERROR HY000: `row_start` must be of type TIMESTAMP(6) for system-versioned table `#sql-temporary`
drop table t1;
create or replace table t ( create or replace table t (
a int primary key, a int primary key,
row_start bigint unsigned as row start invisible, row_start bigint unsigned as row start invisible,
......
create table t ( create or replace table t(
id int primary key, id int,
KEY_TYPE(id),
x int, x int,
row_start SYS_DATATYPE as row start invisible, row_start SYS_DATATYPE as row start invisible,
row_end SYS_DATATYPE as row end invisible, row_end SYS_DATATYPE as row end invisible,
period for system_time (row_start, row_end) period for system_time(row_start, row_end)
) with system versioning; ) with system versioning;
insert t values (1, 2); insert t values (1, 2);
replace t values (1, 3); replace t values (1, 3);
...@@ -32,7 +33,8 @@ insert into t1 values (1,1); ...@@ -32,7 +33,8 @@ insert into t1 values (1,1);
create or replace table t2 (c int); create or replace table t2 (c int);
create or replace view v as select t1.* from t1 join t2; create or replace view v as select t1.* from t1 join t2;
replace into v (a, b) select a, b from t1; replace into v (a, b) select a, b from t1;
drop table t1; drop view v;
drop tables t1, t2;
CREATE TABLE t1 ( CREATE TABLE t1 (
pk INT AUTO_INCREMENT, pk INT AUTO_INCREMENT,
f INT, f INT,
......
...@@ -153,21 +153,21 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -153,21 +153,21 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
Warnings: Warnings:
Note 1003 select `test2`.`t1`.`x` AS `IJ2_x1`,`test2`.`t1`.`y` AS `y1`,`test2`.`t2`.`x` AS `x2`,`test2`.`t2`.`y` AS `y2` from `test2`.`t1` FOR SYSTEM_TIME ALL join `test2`.`t2` FOR SYSTEM_TIME ALL where `test2`.`t1`.`x` = `test2`.`t2`.`x` and `test2`.`t2`.`row_end` > @`t0` and `test2`.`t2`.`row_start` <= @`t0` and `test2`.`t1`.`row_end` > @`t0` and `test2`.`t1`.`row_start` <= @`t0` Note 1003 select `test`.`t1`.`x` AS `IJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL join `test`.`t2` FOR SYSTEM_TIME ALL where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t2`.`row_end` > @`t0` and `test`.`t2`.`row_start` <= @`t0` and `test`.`t1`.`row_end` > @`t0` and `test`.`t1`.`row_start` <= @`t0`
explain extended select * from (select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x) explain extended select * from (select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t; for system_time as of timestamp @t0 as t;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings: Warnings:
Note 1003 select `test2`.`t1`.`x` AS `LJ2_x1`,`test2`.`t1`.`y` AS `y1`,`test2`.`t2`.`x` AS `x2`,`test2`.`t2`.`y` AS `y2` from `test2`.`t1` FOR SYSTEM_TIME ALL left join `test2`.`t2` FOR SYSTEM_TIME ALL on(`test2`.`t2`.`x` = `test2`.`t1`.`x` and `test2`.`t2`.`row_end` > @`t0` and `test2`.`t2`.`row_start` <= @`t0`) where `test2`.`t1`.`row_end` > @`t0` and `test2`.`t1`.`row_start` <= @`t0` Note 1003 select `test`.`t1`.`x` AS `LJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL left join `test`.`t2` FOR SYSTEM_TIME ALL on(`test`.`t2`.`x` = `test`.`t1`.`x` and `test`.`t2`.`row_end` > @`t0` and `test`.`t2`.`row_start` <= @`t0`) where `test`.`t1`.`row_end` > @`t0` and `test`.`t1`.`row_start` <= @`t0`
explain extended select * from (select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x) explain extended select * from (select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t; for system_time as of timestamp @t0 as t;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
Warnings: Warnings:
Note 1003 select `test2`.`t1`.`x` AS `RJ2_x1`,`test2`.`t1`.`y` AS `y1`,`test2`.`t2`.`x` AS `x2`,`test2`.`t2`.`y` AS `y2` from `test2`.`t2` FOR SYSTEM_TIME ALL left join `test2`.`t1` FOR SYSTEM_TIME ALL on(`test2`.`t1`.`x` = `test2`.`t2`.`x` and `test2`.`t1`.`row_end` > @`t0` and `test2`.`t1`.`row_start` <= @`t0`) where `test2`.`t2`.`row_end` > @`t0` and `test2`.`t2`.`row_start` <= @`t0` Note 1003 select `test`.`t1`.`x` AS `RJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t2` FOR SYSTEM_TIME ALL left join `test`.`t1` FOR SYSTEM_TIME ALL on(`test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`row_end` > @`t0` and `test`.`t1`.`row_start` <= @`t0`) where `test`.`t2`.`row_end` > @`t0` and `test`.`t2`.`row_start` <= @`t0`
select * from (select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x) select * from (select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t; for system_time as of timestamp @t0 as t;
IJ2_x1 y1 x2 y2 IJ2_x1 y1 x2 y2
...@@ -294,7 +294,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -294,7 +294,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings: Warnings:
Note 1003 select `test2`.`t1`.`a` AS `a`,`test2`.`t2`.`a` AS `a` from `test2`.`t1` FOR SYSTEM_TIME ALL left join (`test2`.`t1` FOR SYSTEM_TIME ALL `t2` left join `test2`.`t1` FOR SYSTEM_TIME ALL `t3` on(`test2`.`t3`.`a` = `test2`.`t2`.`a` and `test2`.`t3`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999')) on(`test2`.`t2`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999' and `test2`.`t1`.`a` > 1) where `test2`.`t1`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999' Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` FOR SYSTEM_TIME ALL left join (`test`.`t1` FOR SYSTEM_TIME ALL `t2` left join `test`.`t1` FOR SYSTEM_TIME ALL `t3` on(`test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t3`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999')) on(`test`.`t2`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999' and `test`.`t1`.`a` > 1) where `test`.`t1`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999'
select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
a a a a
2 1 2 1
...@@ -511,7 +511,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -511,7 +511,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings: Warnings:
Note 1003 select `test2`.`t1`.`f1` AS `f1` from `test2`.`t1` FOR SYSTEM_TIME ALL join `test2`.`t2` left join (`test2`.`t3` left join `test2`.`t4` FOR SYSTEM_TIME ALL on(`test2`.`t4`.`f4` = `test2`.`t2`.`f2` and `test2`.`t4`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999')) on(`test2`.`t3`.`f3` = `test2`.`t2`.`f2`) where `test2`.`t1`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999' Note 1003 select `test`.`t1`.`f1` AS `f1` from `test`.`t1` FOR SYSTEM_TIME ALL join `test`.`t2` left join (`test`.`t3` left join `test`.`t4` FOR SYSTEM_TIME ALL on(`test`.`t4`.`f4` = `test`.`t2`.`f2` and `test`.`t4`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999')) on(`test`.`t3`.`f3` = `test`.`t2`.`f2`) where `test`.`t1`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999'
drop view v1; drop view v1;
drop table t1, t2, t3, t4; drop table t1, t2, t3, t4;
# #
......
...@@ -93,7 +93,7 @@ drop view v; ...@@ -93,7 +93,7 @@ drop view v;
create or replace table t (i int); create or replace table t (i int);
create or replace view v as select * from t; create or replace view v as select * from t;
drop table v; drop table v;
ERROR 42S02: 'test2.v' is a view ERROR 42S02: 'test.v' is a view
lock table v write; lock table v write;
delete history from v before system_time now(6); delete history from v before system_time now(6);
ERROR 42S02: 'v' is a view ERROR 42S02: 'v' is a view
......
...@@ -181,9 +181,7 @@ select row_start from t1 into @trx_id; ...@@ -181,9 +181,7 @@ select row_start from t1 into @trx_id;
select trt_begin_ts(@trx_id) <= @ts1 as BEGIN_TS_GOOD; select trt_begin_ts(@trx_id) <= @ts1 as BEGIN_TS_GOOD;
BEGIN_TS_GOOD BEGIN_TS_GOOD
1 1
drop database test; drop table t1;
create database test;
use test;
# #
# MDEV-16100 FOR SYSTEM_TIME erroneously resolves string user variables as transaction IDs # MDEV-16100 FOR SYSTEM_TIME erroneously resolves string user variables as transaction IDs
# #
......
...@@ -12,7 +12,7 @@ insert into t1 select * from t1; ...@@ -12,7 +12,7 @@ insert into t1 select * from t1;
insert into t1 select * from t1; insert into t1 select * from t1;
insert into t1 select * from t1; insert into t1 select * from t1;
insert into t1 select * from t1; insert into t1 select * from t1;
connect con1,localhost,root,,test2; connect con1,localhost,root,,test;
alter table t1 add system versioning; alter table t1 add system versioning;
connection default; connection default;
update t1 set a= 7 where a = 3; update t1 set a= 7 where a = 3;
......
...@@ -241,3 +241,27 @@ B2 salary ...@@ -241,3 +241,27 @@ B2 salary
1 2500 1 2500
drop table t1; drop table t1;
drop table t2; drop table t2;
### Issue tempesta-tech/mariadb#365, bug 7 (duplicate of historical row)
create or replace table t1 (a int primary key, b int)
with system versioning engine myisam;
insert into t1 (a) values (1);
replace t1 values (1,2),(1,3),(2,4);
#
# MDEV-14829 Assertion `0' failed in Protocol::end_statement upon concurrent UPDATE
#
create or replace table t1 (pk int, a char(3), b char(3), primary key(pk))
engine=innodb with system versioning;
insert into t1 (pk) values (1);
connect con1,localhost,root,,test;
start transaction;
select * from t1 for update;
pk a b
1 NULL NULL
connection default;
update t1 set b = 'foo';
connection con1;
update t1 set a = 'bar';
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
disconnect con1;
connection default;
drop table t1;
### Issue #365, bug 7 (duplicate of historical row)
create or replace table t1 (a int primary key, b int)
with system versioning engine myisam;
insert into t1 (a) values (1);
replace t1 values (1,2),(1,3),(2,4);
create or replace table t1 (pk int, a char(3), b char(3), primary key(pk))
engine=innodb with system versioning;
insert into t1 (pk) values (1);
connect con1,localhost,root,,test;
start transaction;
select * from t1 for update;
pk a b
1 NULL NULL
connection default;
update t1 set b = 'foo';
connection con1;
update t1 set a = 'bar';
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
disconnect con1;
connection default;
drop table t1;
...@@ -118,9 +118,8 @@ execute stmt; ...@@ -118,9 +118,8 @@ execute stmt;
a a
execute stmt; execute stmt;
a a
drop database test2; drop view v1;
create database test2; drop tables t1, t2;
use test2;
# #
# MDEV-15146 SQLError[4122]: View is not system versioned # MDEV-15146 SQLError[4122]: View is not system versioned
# #
...@@ -148,5 +147,5 @@ create or replace view v1 as select * from t1 for system_time as of date_sub(now ...@@ -148,5 +147,5 @@ create or replace view v1 as select * from t1 for system_time as of date_sub(now
show create view v1; show create view v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` FOR SYSTEM_TIME AS OF current_timestamp() - interval 6 second latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` FOR SYSTEM_TIME AS OF current_timestamp() - interval 6 second latin1 latin1_swedish_ci
drop view v1; drop view v1, vt1, vt12;
drop table t1; drop tables t1, t3;
...@@ -453,7 +453,7 @@ use mysql; ...@@ -453,7 +453,7 @@ use mysql;
create or replace table t (x int) with system versioning; create or replace table t (x int) with system versioning;
--error ER_VERS_DB_NOT_SUPPORTED --error ER_VERS_DB_NOT_SUPPORTED
alter table user add system versioning; alter table user add system versioning;
use test2; use test;
--echo # MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column --echo # MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column
create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning; create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning;
...@@ -574,5 +574,4 @@ alter table t ...@@ -574,5 +574,4 @@ alter table t
change column c c int, change column c c int,
change column b b int without system versioning; change column b b int without system versioning;
drop database test; drop table t;
create database test;
...@@ -405,5 +405,4 @@ create or replace table t1 (x int without system versioning) ...@@ -405,5 +405,4 @@ create or replace table t1 (x int without system versioning)
with system versioning with system versioning
select 1 as x; select 1 as x;
drop database test; drop tables t0, t1, t2, t3;
create database test;
...@@ -81,5 +81,6 @@ insert into t1 values (1); ...@@ -81,5 +81,6 @@ insert into t1 values (1);
update t1 set x= 2; update t1 set x= 2;
delete from t1; delete from t1;
select x from t1 for system_time all; select x from t1 for system_time all;
drop table t1;
--source suite/versioning/common_finish.inc --source suite/versioning/common_finish.inc
[timestamp]
default-storage-engine=innodb
[trx_id]
default-storage-engine=innodb
[myisam]
default-storage-engine=myisam
--source suite/versioning/common.inc --source suite/versioning/common.inc
let $KEY_TYPE= primary key;
--echo ################# --echo #################
--echo # Test RESTRICT # --echo # Test RESTRICT #
--echo ################# --echo #################
create table parent( --replace_result "$KEY_TYPE" KEY_TYPE
id int unique key eval create table parent(
id int,
$KEY_TYPE (id)
) engine innodb; ) engine innodb;
--replace_result $sys_datatype_expl SYS_DATATYPE --replace_result $sys_datatype_expl SYS_DATATYPE
...@@ -42,8 +46,10 @@ drop table parent; ...@@ -42,8 +46,10 @@ drop table parent;
--echo # Test when clustered index is a foreign key # --echo # Test when clustered index is a foreign key #
--echo ############################################## --echo ##############################################
create table parent( --replace_result "$KEY_TYPE" KEY_TYPE
id int(10) unsigned unique key eval create table parent(
id int(10) unsigned,
$KEY_TYPE (id)
) engine innodb; ) engine innodb;
--replace_result $sys_datatype_expl SYS_DATATYPE --replace_result $sys_datatype_expl SYS_DATATYPE
...@@ -68,8 +74,10 @@ drop table parent; ...@@ -68,8 +74,10 @@ drop table parent;
--echo # Test CASCADE # --echo # Test CASCADE #
--echo ################ --echo ################
create table parent( --replace_result "$KEY_TYPE" KEY_TYPE
id int unique key eval create table parent(
id int,
$KEY_TYPE (id)
) engine innodb; ) engine innodb;
--replace_result $sys_datatype_expl SYS_DATATYPE --replace_result $sys_datatype_expl SYS_DATATYPE
...@@ -99,9 +107,10 @@ select * from child for system_time all; ...@@ -99,9 +107,10 @@ select * from child for system_time all;
drop table child; drop table child;
drop table parent; drop table parent;
--replace_result $sys_datatype_expl SYS_DATATYPE --replace_result $sys_datatype_expl SYS_DATATYPE "$KEY_TYPE" KEY_TYPE
eval create or replace table parent ( eval create or replace table parent (
id int primary key, id int,
$KEY_TYPE(id),
sys_start $sys_datatype_expl as row start invisible, sys_start $sys_datatype_expl as row start invisible,
sys_end $sys_datatype_expl as row end invisible, sys_end $sys_datatype_expl as row end invisible,
period for system_time(sys_start, sys_end) period for system_time(sys_start, sys_end)
...@@ -126,8 +135,10 @@ select * from child; ...@@ -126,8 +135,10 @@ select * from child;
drop table child; drop table child;
drop table parent; drop table parent;
create or replace table parent ( --replace_result "$KEY_TYPE" KEY_TYPE
id int primary key eval create or replace table parent (
id int,
$KEY_TYPE(id)
) )
engine innodb; engine innodb;
...@@ -158,8 +169,10 @@ drop table parent; ...@@ -158,8 +169,10 @@ drop table parent;
--echo # Test SET NULL # --echo # Test SET NULL #
--echo ################# --echo #################
create or replace table parent( --replace_result "$KEY_TYPE" KEY_TYPE
id int unique key eval create table parent(
id int,
$KEY_TYPE (id)
) engine innodb; ) engine innodb;
--replace_result $sys_datatype_expl SYS_DATATYPE --replace_result $sys_datatype_expl SYS_DATATYPE
...@@ -196,9 +209,10 @@ drop table parent; ...@@ -196,9 +209,10 @@ drop table parent;
--echo # Parent table is foreign # --echo # Parent table is foreign #
--echo ########################### --echo ###########################
--replace_result $sys_datatype_expl SYS_DATATYPE --replace_result $sys_datatype_expl SYS_DATATYPE "$KEY_TYPE" KEY_TYPE
eval create or replace table parent( eval create or replace table parent(
id int unique key, id int,
$KEY_TYPE (id),
sys_start $sys_datatype_expl as row start invisible, sys_start $sys_datatype_expl as row start invisible,
sys_end $sys_datatype_expl as row end invisible, sys_end $sys_datatype_expl as row end invisible,
period for system_time(sys_start, sys_end) period for system_time(sys_start, sys_end)
...@@ -236,9 +250,10 @@ drop table parent; ...@@ -236,9 +250,10 @@ drop table parent;
--echo # crash on DELETE # --echo # crash on DELETE #
--echo ################### --echo ###################
--replace_result $sys_datatype_expl SYS_DATATYPE --replace_result $sys_datatype_expl SYS_DATATYPE "$KEY_TYPE" KEY_TYPE
eval create or replace table a ( eval create or replace table a (
cola int(10) primary key, cola int(10),
$KEY_TYPE (cola),
v_cola int(10) as (cola mod 10) virtual, v_cola int(10) as (cola mod 10) virtual,
sys_start $sys_datatype_expl as row start invisible, sys_start $sys_datatype_expl as row start invisible,
sys_end $sys_datatype_expl as row end invisible, sys_end $sys_datatype_expl as row end invisible,
...@@ -406,8 +421,8 @@ REPLACE INTO t2 SELECT * FROM t2; ...@@ -406,8 +421,8 @@ REPLACE INTO t2 SELECT * FROM t2;
# Cleanup # Cleanup
DROP TABLE t1, t2; DROP TABLE t1, t2;
--let $datadir= `select @@datadir` --let $datadir= `select @@datadir`
--remove_file $datadir/test2/t1.data --remove_file $datadir/test/t1.data
--remove_file $datadir/test2/t1.data.2 --remove_file $datadir/test/t1.data.2
--remove_file $datadir/test2/t2.data --remove_file $datadir/test/t2.data
--source suite/versioning/common_finish.inc --source suite/versioning/common_finish.inc
...@@ -107,7 +107,7 @@ insert into t values (1, 1); ...@@ -107,7 +107,7 @@ insert into t values (1, 1);
select c.prtype from information_schema.innodb_sys_columns as c select c.prtype from information_schema.innodb_sys_columns as c
join information_schema.innodb_sys_tables as t on c.table_id=t.table_id join information_schema.innodb_sys_tables as t on c.table_id=t.table_id
where t.name='test2/t' and c.name='b'; where t.name='test/t' and c.name='b';
set @@system_versioning_alter_history=keep; set @@system_versioning_alter_history=keep;
...@@ -125,7 +125,7 @@ set debug_dbug= default; ...@@ -125,7 +125,7 @@ set debug_dbug= default;
select c.prtype from information_schema.innodb_sys_columns as c select c.prtype from information_schema.innodb_sys_columns as c
join information_schema.innodb_sys_tables as t on c.table_id=t.table_id join information_schema.innodb_sys_tables as t on c.table_id=t.table_id
where t.name='test2/t' and c.name='b'; where t.name='test/t' and c.name='b';
--replace_result $sys_datatype_expl SYS_DATATYPE --replace_result $sys_datatype_expl SYS_DATATYPE
show create table t; show create table t;
......
...@@ -402,17 +402,17 @@ partition by system_time interval 1 hour ( ...@@ -402,17 +402,17 @@ partition by system_time interval 1 hour (
partition p0 history, partition pn current); partition p0 history, partition pn current);
set @ts=(select partition_description from information_schema.partitions set @ts=(select partition_description from information_schema.partitions
where table_schema='test2' and table_name='t1' and partition_name='p0'); where table_schema='test' and table_name='t1' and partition_name='p0');
alter table t1 add column b int; alter table t1 add column b int;
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test2' and table_name='t1'; select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
alter table t1 add partition (partition p1 history, partition p2 history); alter table t1 add partition (partition p1 history, partition p2 history);
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test2' and table_name='t1'; select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
alter table t1 drop partition p0; alter table t1 drop partition p0;
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test2' and table_name='t1'; select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
--error ER_VERS_DROP_PARTITION_INTERVAL --error ER_VERS_DROP_PARTITION_INTERVAL
alter table t1 drop partition p2; alter table t1 drop partition p2;
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test2' and table_name='t1'; select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
--echo # --echo #
--echo # MDEV-15103 Assertion in ha_partition::part_records() for updating VIEW --echo # MDEV-15103 Assertion in ha_partition::part_records() for updating VIEW
...@@ -513,6 +513,8 @@ unlock tables; ...@@ -513,6 +513,8 @@ unlock tables;
--echo # --echo #
create or replace table t1 (pk int primary key) with system versioning partition by system_time limit 100 (partition p1 history, partition pn current); create or replace table t1 (pk int primary key) with system versioning partition by system_time limit 100 (partition p1 history, partition pn current);
execute immediate 'select * from t1 for update'; execute immediate 'select * from t1 for update';
drop table t1;
drop view v1;
drop tables t, t1, t2, t3, t4;
--source suite/versioning/common_finish.inc --source suite/versioning/common_finish.inc
...@@ -29,6 +29,8 @@ alter table t1 partition by system_time ( ...@@ -29,6 +29,8 @@ alter table t1 partition by system_time (
partition pn current partition pn current
); );
drop table t1;
--error ER_VERS_TRX_PART_HISTORIC_ROW_NOT_SUPPORTED --error ER_VERS_TRX_PART_HISTORIC_ROW_NOT_SUPPORTED
create or replace table t ( create or replace table t (
a int primary key, a int primary key,
......
--source suite/versioning/key_type.inc
if ($MTR_COMBINATION_SEC)
{
--skip pk or unique only
}
--source suite/versioning/common.inc --source suite/versioning/common.inc
--source suite/versioning/engines.inc --source suite/versioning/engines.inc
--replace_result $sys_datatype_expl SYS_DATATYPE --replace_result $sys_datatype_expl SYS_DATATYPE "$KEY_TYPE" KEY_TYPE
eval create table t ( eval create or replace table t(
id int primary key, id int,
$KEY_TYPE(id),
x int, x int,
row_start $sys_datatype_expl as row start invisible, row_start $sys_datatype_expl as row start invisible,
row_end $sys_datatype_expl as row end invisible, row_end $sys_datatype_expl as row end invisible,
period for system_time (row_start, row_end) period for system_time(row_start, row_end)
) with system versioning; ) with system versioning;
insert t values (1, 2); insert t values (1, 2);
...@@ -35,7 +41,8 @@ insert into t1 values (1,1); ...@@ -35,7 +41,8 @@ insert into t1 values (1,1);
create or replace table t2 (c int); create or replace table t2 (c int);
create or replace view v as select t1.* from t1 join t2; create or replace view v as select t1.* from t1 join t2;
replace into v (a, b) select a, b from t1; replace into v (a, b) select a, b from t1;
drop table t1; drop view v;
drop tables t1, t2;
--replace_result $sys_datatype_expl SYS_DATATYPE --replace_result $sys_datatype_expl SYS_DATATYPE
eval CREATE TABLE t1 ( eval CREATE TABLE t1 (
......
...@@ -173,10 +173,7 @@ commit; ...@@ -173,10 +173,7 @@ commit;
select row_start from t1 into @trx_id; select row_start from t1 into @trx_id;
select trt_begin_ts(@trx_id) <= @ts1 as BEGIN_TS_GOOD; select trt_begin_ts(@trx_id) <= @ts1 as BEGIN_TS_GOOD;
drop database test; drop table t1;
create database test;
use test;
--echo # --echo #
--echo # MDEV-16100 FOR SYSTEM_TIME erroneously resolves string user variables as transaction IDs --echo # MDEV-16100 FOR SYSTEM_TIME erroneously resolves string user variables as transaction IDs
......
...@@ -17,7 +17,7 @@ insert into t1 select * from t1; ...@@ -17,7 +17,7 @@ insert into t1 select * from t1;
insert into t1 select * from t1; insert into t1 select * from t1;
insert into t1 select * from t1; insert into t1 select * from t1;
--connect (con1,localhost,root,,test2) --connect (con1,localhost,root,,test)
alter table t1 add system versioning; alter table t1 add system versioning;
--connection default --connection default
......
...@@ -147,4 +147,34 @@ select @tmp2 = sys_trx_start as B2, salary from t2; ...@@ -147,4 +147,34 @@ select @tmp2 = sys_trx_start as B2, salary from t2;
drop table t1; drop table t1;
drop table t2; drop table t2;
--echo ### Issue tempesta-tech/mariadb#365, bug 7 (duplicate of historical row)
create or replace table t1 (a int primary key, b int)
with system versioning engine myisam;
insert into t1 (a) values (1);
replace t1 values (1,2),(1,3),(2,4);
--echo #
--echo # MDEV-14829 Assertion `0' failed in Protocol::end_statement upon concurrent UPDATE
--echo #
create or replace table t1 (pk int, a char(3), b char(3), primary key(pk))
engine=innodb with system versioning;
insert into t1 (pk) values (1);
connect (con1,localhost,root,,test);
start transaction;
select * from t1 for update;
connection default;
send update t1 set b = 'foo';
connection con1;
let $wait_condition= select count(*) from information_schema.innodb_lock_waits;
source include/wait_condition.inc;
error ER_LOCK_DEADLOCK;
update t1 set a = 'bar';
disconnect con1;
connection default;
reap;
drop table t1;
source suite/versioning/common_finish.inc; source suite/versioning/common_finish.inc;
source include/have_innodb.inc;
echo ### Issue #365, bug 7 (duplicate of historical row);
create or replace table t1 (a int primary key, b int)
with system versioning engine myisam;
insert into t1 (a) values (1);
replace t1 values (1,2),(1,3),(2,4);
#
# MDEV-14829 Assertion `0' failed in Protocol::end_statement upon concurrent UPDATE
#
create or replace table t1 (pk int, a char(3), b char(3), primary key(pk))
engine=innodb with system versioning;
insert into t1 (pk) values (1);
connect (con1,localhost,root,,test);
start transaction;
select * from t1 for update;
connection default;
send update t1 set b = 'foo';
connection con1;
let $wait_condition= select count(*) from information_schema.innodb_lock_waits;
source include/wait_condition.inc;
error ER_LOCK_DEADLOCK;
update t1 set a = 'bar';
disconnect con1;
connection default;
reap;
drop table t1;
...@@ -98,9 +98,8 @@ create or replace table t2 (b int) with system versioning; ...@@ -98,9 +98,8 @@ create or replace table t2 (b int) with system versioning;
prepare stmt from 'select a from v1 inner join t2 group by a order by a'; prepare stmt from 'select a from v1 inner join t2 group by a order by a';
execute stmt; execute stmt;
execute stmt; execute stmt;
drop database test2; drop view v1;
create database test2; drop tables t1, t2;
use test2;
--echo # --echo #
--echo # MDEV-15146 SQLError[4122]: View is not system versioned --echo # MDEV-15146 SQLError[4122]: View is not system versioned
...@@ -122,7 +121,7 @@ select * from t1 for system_time as of now() - interval 6 second; ...@@ -122,7 +121,7 @@ select * from t1 for system_time as of now() - interval 6 second;
create or replace view v1 as select * from t1 for system_time as of date_sub(now(), interval 6 second); create or replace view v1 as select * from t1 for system_time as of date_sub(now(), interval 6 second);
show create view v1; show create view v1;
drop view v1; drop view v1, vt1, vt12;
drop table t1; drop tables t1, t3;
--source suite/versioning/common_finish.inc --source suite/versioning/common_finish.inc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment