mariadb/mysql-test/suite/versioning/t/view.test
Sergei Golubchik f51ecfee93 MDEV-15146 SQLError[4122]: View is not system versioned
don't expand AS OF in views, and, in particular, don't auto-add
AS OF NOW().
2018-02-12 23:43:48 +01:00

116 lines
3.9 KiB
Text

--source suite/versioning/engines.inc
--source suite/versioning/common.inc
create or replace table t1 (x int) with system versioning;
insert into t1 values (1);
select now(6) into @t1;
update t1 set x= 2;
select now(6) into @t2;
delete from t1;
set @vt1= concat("create or replace view vt1 as select * from t1 for system_time as of timestamp '", @t1, "'");
prepare stmt from @vt1; execute stmt; drop prepare stmt;
set @vt2= concat("create or replace view vt2 as select *, row_end from t1 for system_time as of timestamp '", @t2, "'");
prepare stmt from @vt2; execute stmt; drop prepare stmt;
select * from t1;
create or replace view vt1 as select * from t1;
--replace_result 18446744073709551615 MAX_RESULT "TIMESTAMP'2038-01-19 03:14:07.999999'" MAX_RESULT
show create view vt1;
drop view vt1;
drop view vt2;
create or replace view vt1 as select * from t1 for system_time all;
select * from vt1;
prepare stmt from 'select * from vt1'; execute stmt; drop prepare stmt;
set @str= concat('create or replace view vt1 as
select * from t1 for system_time as of timestamp "', @t1, '"');
prepare stmt from @str; execute stmt; drop prepare stmt;
select * from t1 for system_time as of timestamp @t1;
select * from vt1;
insert into vt1 values (3);
select * from t1;
select * from vt1;
create or replace table t1 (x int) with system versioning;
insert into t1 values (1), (2);
set @t1=now(6);
delete from t1 where x=2;
set @t2=now(6);
delete from t1 where x=1;
set @t3=now(6);
set @tmp= concat("create or replace view vt1 as select * from t1 for system_time as of timestamp '", @t1, "'");
prepare stmt from @tmp; execute stmt; drop prepare stmt;
select * from vt1;
--echo # VIEW with parameters [#151]
create or replace table t1 (x int) with system versioning;
create or replace view vt1(c) as select x from t1;
--replace_result 18446744073709551615 MAX_RESULT "TIMESTAMP'2038-01-19 03:14:07.999999'" MAX_RESULT
show create view vt1;
--echo # VIEW over JOIN of versioned tables [#153]
create or replace table t1 (a int) with system versioning;
create or replace table t2 (b int) with system versioning;
insert into t1 values (1);
insert into t2 values (2);
create or replace view vt12 as select * from t1 cross join t2;
select * from vt12;
create or replace view vt12 as select * from t1 for system_time as of timestamp '0-0-0' cross join t2;
select * from vt12;
--echo # VIEW improvements [#183]
create or replace table t3 (x int);
create or replace view vt1 as select * from t1, t2, t3;
--replace_result 18446744073709551615 MAX_RESULT "TIMESTAMP'2038-01-19 03:14:07.999999'" MAX_RESULT
show create view vt1;
create or replace view vt1 as select * from t3, t2, t1;
--replace_result 18446744073709551615 MAX_RESULT "TIMESTAMP'2038-01-19 03:14:07.999999'" MAX_RESULT
show create view vt1;
create or replace view vt1 as select a, t2.row_end as endo from t3, t1, t2;
--replace_result 18446744073709551615 MAX_RESULT "TIMESTAMP'2038-01-19 03:14:07.999999'" MAX_RESULT
show create view vt1;
--echo # VIEW over UNION [#269]
create or replace view vt1 as select * from t1 union select * from t1;
select * from vt1;
--echo # VIEW over UNION with non-versioned [#393]
create or replace table t2 (a int);
create or replace view vt1 as select * from t1 union select * from t2;
select * from vt1;
--echo # MDEV-14689 crash on second PS execute
create or replace table t1 (a int);
create or replace view v1 as select * from t1;
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';
execute stmt;
execute stmt;
drop database test;
create database test;
use test;
#
# MDEV-15146 SQLError[4122]: View is not system versioned
#
create table t1 (a int) with system versioning;
insert t1 values (1),(2);
set @a=now(6);
create view v1 as select * from t1;
delete from t1;
select * from v1;
select * from v1 for system_time as of @a;
show create view v1;
drop view v1;
drop table t1;