1
0
mirror of https://github.com/MariaDB/server.git synced 2025-05-28 13:01:41 +03:00
Aleksey Midenkov b55a149194
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'
2017-12-18 19:03:51 +03:00

74 lines
2.2 KiB
Plaintext

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 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 sys_trx_start into @ts_2 from emp where name="bill";
select * from emp;
emp_id dept_id name salary
1 10 bill 1000
update emp set salary=2000 where name="bill";
commit;
select sys_trx_start into @ts_3 from emp where name="bill";
select * from emp;
emp_id dept_id name salary
1 10 bill 2000
select * from emp for system_time as of timestamp @ts_2;
emp_id dept_id name salary
1 10 bill 1000
select * from emp for system_time as of timestamp @ts_3;
emp_id dept_id name salary
1 10 bill 2000
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id;
emp_id dept_id name salary dept_id name
1 10 bill 2000 10 accounting
select * from
emp for system_time from timestamp @ts_1 to timestamp @ts_2 e,
dept for system_time from timestamp @ts_1 to timestamp @ts_2 d
where d.dept_id = 10
and d.dept_id = e.dept_id;
emp_id dept_id name salary sys_trx_start sys_trx_end dept_id name sys_trx_start sys_trx_end
set statement system_versioning_asof=@ts_0 for
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id;
emp_id dept_id name salary dept_id name
set statement system_versioning_asof=@ts_1 for
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id;
emp_id dept_id name salary dept_id name
set statement system_versioning_asof=@ts_2 for
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id;
emp_id dept_id name salary dept_id name
1 10 bill 1000 10 accounting
set statement system_versioning_asof=@ts_3 for
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id;
emp_id dept_id name salary dept_id name
1 10 bill 2000 10 accounting
drop table emp, dept;