Commit c3e09a2d authored by Nikita Malyavin's avatar Nikita Malyavin

MDEV-22439 Add FOR PORTION OF statements to the test for WITHOUT OVERLAPS

parent b1ab211d
......@@ -3,4 +3,5 @@ innodb
default-storage-engine=innodb
[myisam]
innodb
default-storage-engine=myisam
......@@ -62,6 +62,61 @@ id s e
1 2003-01-01 2003-02-01
1 2003-03-01 2003-05-01
1 2003-05-01 2003-07-01
# UPDATE ... FOR PORTION test
insert t values (2, '2003-04-15', '2003-05-01');
update t for portion of p from '2003-01-01' to '2003-01-15'
set id= 2;
select * from t;
id s e
1 2003-01-15 2003-02-01
1 2003-03-01 2003-05-01
1 2003-05-01 2003-07-01
2 2003-01-01 2003-01-15
2 2003-04-15 2003-05-01
update t for portion of p from '2003-01-15' to '2003-02-01'
set id= 2;
select * from t;
id s e
1 2003-03-01 2003-05-01
1 2003-05-01 2003-07-01
2 2003-01-01 2003-01-15
2 2003-01-15 2003-02-01
2 2003-04-15 2003-05-01
# Next, test UPDATE ... FOR PORTION resulting with an error
# Since MyISAM/Aria engines lack atomicity, the results would differ with
# innodb. So a table is going to be copied to one with explicit engine.
create table t_myisam (id int, s date, e date,
period for p(s,e),
primary key(id, p without overlaps))
engine=myisam
select * from t;
update t_myisam for portion of p from '2003-04-01' to '2003-06-01'
set id= 2 order by s desc;
ERROR 23000: Duplicate entry '2-2003-05-01-2003-04-01' for key 'PRIMARY'
select * from t_myisam;
id s e
1 2003-03-01 2003-05-01
1 2003-06-01 2003-07-01
2 2003-01-01 2003-01-15
2 2003-01-15 2003-02-01
2 2003-04-15 2003-05-01
2 2003-05-01 2003-06-01
create table t_innodb (id int, s date, e date,
period for p(s,e),
primary key(id, p without overlaps))
engine=innodb
select * from t;
update t_innodb for portion of p from '2003-04-01' to '2003-06-01'
set id= 2 order by s desc;
ERROR 23000: Duplicate entry '2-2003-05-01-2003-04-01' for key 'PRIMARY'
select * from t_innodb;
id s e
1 2003-03-01 2003-05-01
1 2003-05-01 2003-07-01
2 2003-01-01 2003-01-15
2 2003-01-15 2003-02-01
2 2003-04-15 2003-05-01
drop table t_myisam, t_innodb;
create or replace table t(id int, s date, e date,
period for p(s,e),
primary key(id, q without overlaps));
......
......@@ -67,6 +67,47 @@ update t set e= '2003-05-01' where s = '2003-01-01';
select * from t where year(s) = 2003;
--echo # UPDATE ... FOR PORTION test
insert t values (2, '2003-04-15', '2003-05-01');
update t for portion of p from '2003-01-01' to '2003-01-15'
set id= 2;
--sorted_result
select * from t;
update t for portion of p from '2003-01-15' to '2003-02-01'
set id= 2;
--sorted_result
select * from t;
--echo # Next, test UPDATE ... FOR PORTION resulting with an error
--echo # Since MyISAM/Aria engines lack atomicity, the results would differ with
--echo # innodb. So a table is going to be copied to one with explicit engine.
create table t_myisam (id int, s date, e date,
period for p(s,e),
primary key(id, p without overlaps))
engine=myisam
select * from t;
--error ER_DUP_ENTRY
update t_myisam for portion of p from '2003-04-01' to '2003-06-01'
set id= 2 order by s desc;
--sorted_result
select * from t_myisam;
create table t_innodb (id int, s date, e date,
period for p(s,e),
primary key(id, p without overlaps))
engine=innodb
select * from t;
--error ER_DUP_ENTRY
update t_innodb for portion of p from '2003-04-01' to '2003-06-01'
set id= 2 order by s desc;
--sorted_result
select * from t_innodb;
drop table t_myisam, t_innodb;
--error ER_PERIOD_NOT_FOUND
create or replace table t(id int, s date, e date,
period for p(s,e),
......
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