1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-20 05:03:09 +03:00
Files
mariadb/mysql-test/suite/versioning/t/simple.test
2017-12-05 17:46:01 +03:00

73 lines
1.7 KiB
Plaintext

-- source include/have_innodb.inc
set default_storage_engine=innodb;
create or replace table dept (
dept_id int(10) primary key,
name varchar(100)
)
with system versioning;
create or replace table emp (
emp_id int(10) primary key,
dept_id int(10),
name varchar(100),
salary int(10),
constraint `dept-emp-fk`
foreign key (dept_id) references dept (dept_id)
on delete cascade
on update restrict
)
with system versioning;
select now() into @ts_0;
insert into dept (dept_id, name) values (10, "accounting");
commit;
select vtq_commit_ts(sys_trx_start) into @ts_1 from dept where dept_id=10;
insert into emp (emp_id, name, salary, dept_id) values (1, "bill", 1000, 10);
commit;
select vtq_commit_ts(sys_trx_start) into @ts_2 from emp where name="bill";
select * from emp;
update emp set salary=2000 where name="bill";
commit;
select vtq_commit_ts(sys_trx_start) into @ts_3 from emp where name="bill";
select * from emp;
select * from emp for system_time as of timestamp @ts_2;
select * from emp for system_time as of timestamp @ts_3;
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id;
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id
for system_time from timestamp @ts_1 to timestamp @ts_2;
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id
for system_time as of timestamp @ts_0;
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id
for system_time as of timestamp @ts_1;
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id
for system_time as of timestamp @ts_2;
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id
for system_time as of timestamp @ts_3;
drop table emp, dept;