Skip to content

Commit c3e09a2

Browse files
committed
MDEV-22439 Add FOR PORTION OF statements to the test for WITHOUT OVERLAPS
1 parent b1ab211 commit c3e09a2

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

mysql-test/suite/period/engines.combinations

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ innodb
33
default-storage-engine=innodb
44

55
[myisam]
6+
innodb
67
default-storage-engine=myisam

mysql-test/suite/period/r/overlaps.result

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,61 @@ id s e
6262
1 2003-01-01 2003-02-01
6363
1 2003-03-01 2003-05-01
6464
1 2003-05-01 2003-07-01
65+
# UPDATE ... FOR PORTION test
66+
insert t values (2, '2003-04-15', '2003-05-01');
67+
update t for portion of p from '2003-01-01' to '2003-01-15'
68+
set id= 2;
69+
select * from t;
70+
id s e
71+
1 2003-01-15 2003-02-01
72+
1 2003-03-01 2003-05-01
73+
1 2003-05-01 2003-07-01
74+
2 2003-01-01 2003-01-15
75+
2 2003-04-15 2003-05-01
76+
update t for portion of p from '2003-01-15' to '2003-02-01'
77+
set id= 2;
78+
select * from t;
79+
id s e
80+
1 2003-03-01 2003-05-01
81+
1 2003-05-01 2003-07-01
82+
2 2003-01-01 2003-01-15
83+
2 2003-01-15 2003-02-01
84+
2 2003-04-15 2003-05-01
85+
# Next, test UPDATE ... FOR PORTION resulting with an error
86+
# Since MyISAM/Aria engines lack atomicity, the results would differ with
87+
# innodb. So a table is going to be copied to one with explicit engine.
88+
create table t_myisam (id int, s date, e date,
89+
period for p(s,e),
90+
primary key(id, p without overlaps))
91+
engine=myisam
92+
select * from t;
93+
update t_myisam for portion of p from '2003-04-01' to '2003-06-01'
94+
set id= 2 order by s desc;
95+
ERROR 23000: Duplicate entry '2-2003-05-01-2003-04-01' for key 'PRIMARY'
96+
select * from t_myisam;
97+
id s e
98+
1 2003-03-01 2003-05-01
99+
1 2003-06-01 2003-07-01
100+
2 2003-01-01 2003-01-15
101+
2 2003-01-15 2003-02-01
102+
2 2003-04-15 2003-05-01
103+
2 2003-05-01 2003-06-01
104+
create table t_innodb (id int, s date, e date,
105+
period for p(s,e),
106+
primary key(id, p without overlaps))
107+
engine=innodb
108+
select * from t;
109+
update t_innodb for portion of p from '2003-04-01' to '2003-06-01'
110+
set id= 2 order by s desc;
111+
ERROR 23000: Duplicate entry '2-2003-05-01-2003-04-01' for key 'PRIMARY'
112+
select * from t_innodb;
113+
id s e
114+
1 2003-03-01 2003-05-01
115+
1 2003-05-01 2003-07-01
116+
2 2003-01-01 2003-01-15
117+
2 2003-01-15 2003-02-01
118+
2 2003-04-15 2003-05-01
119+
drop table t_myisam, t_innodb;
65120
create or replace table t(id int, s date, e date,
66121
period for p(s,e),
67122
primary key(id, q without overlaps));

mysql-test/suite/period/t/overlaps.test

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,47 @@ update t set e= '2003-05-01' where s = '2003-01-01';
6767

6868
select * from t where year(s) = 2003;
6969

70+
--echo # UPDATE ... FOR PORTION test
71+
insert t values (2, '2003-04-15', '2003-05-01');
72+
73+
update t for portion of p from '2003-01-01' to '2003-01-15'
74+
set id= 2;
75+
--sorted_result
76+
select * from t;
77+
78+
update t for portion of p from '2003-01-15' to '2003-02-01'
79+
set id= 2;
80+
--sorted_result
81+
select * from t;
82+
83+
--echo # Next, test UPDATE ... FOR PORTION resulting with an error
84+
--echo # Since MyISAM/Aria engines lack atomicity, the results would differ with
85+
--echo # innodb. So a table is going to be copied to one with explicit engine.
86+
87+
create table t_myisam (id int, s date, e date,
88+
period for p(s,e),
89+
primary key(id, p without overlaps))
90+
engine=myisam
91+
select * from t;
92+
--error ER_DUP_ENTRY
93+
update t_myisam for portion of p from '2003-04-01' to '2003-06-01'
94+
set id= 2 order by s desc;
95+
--sorted_result
96+
select * from t_myisam;
97+
98+
create table t_innodb (id int, s date, e date,
99+
period for p(s,e),
100+
primary key(id, p without overlaps))
101+
engine=innodb
102+
select * from t;
103+
--error ER_DUP_ENTRY
104+
update t_innodb for portion of p from '2003-04-01' to '2003-06-01'
105+
set id= 2 order by s desc;
106+
--sorted_result
107+
select * from t_innodb;
108+
109+
drop table t_myisam, t_innodb;
110+
70111
--error ER_PERIOD_NOT_FOUND
71112
create or replace table t(id int, s date, e date,
72113
period for p(s,e),

0 commit comments

Comments
 (0)