Skip to content

Commit 7ec3a4d

Browse files
committed
tests
* don't suppress output unnecessary * only run system versioning tests with two innodb combinations * show results of delete/update (add SELECTs as needed)
1 parent 6294516 commit 7ec3a4d

File tree

10 files changed

+316
-141
lines changed

10 files changed

+316
-141
lines changed

mysql-test/suite/period/create_triggers.inc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
disable_query_log;
2-
3-
create or replace table log_tbl(id int auto_increment primary key, log text);
1+
create or replace table log_tbl(id int auto_increment primary key, log text) engine=myisam;
42

53
create or replace procedure log(s text)
64
insert into log_tbl(log) values(s);
@@ -38,4 +36,3 @@ eval create trigger tr2ins_$trig_table after insert on $trig_table
3836

3937
let trig_cols= 0;
4038
let trig_table= 0;
41-
enable_query_log;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[innodb]
2+
innodb
3+
default-storage-engine=innodb
4+
5+
[myisam]
6+
default-storage-engine=myisam

mysql-test/suite/period/engines.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# see engines.combinations
3+
#
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--- suite/period/r/delete.result 2019-02-16 11:14:23.511258191 +0100
2+
+++ suite/period/r/delete.reject 2019-02-16 11:14:32.869258690 +0100
3+
@@ -250,7 +250,6 @@
4+
ERROR 22003: Out of range value for column 'id' at row 1
5+
select * from t;
6+
id s e
7+
-127 1999-01-01 2018-12-12
8+
# same for trigger case
9+
create or replace table log_tbl(id int auto_increment primary key, log text) engine=myisam;
10+
create or replace procedure log(s text)
11+
@@ -277,7 +276,6 @@
12+
ERROR 22003: Out of range value for column 'id' at row 1
13+
select * from t;
14+
id s e
15+
-127 1999-01-01 2018-12-12
16+
select * from log_tbl order by id;
17+
id log
18+
1 >DEL: 1999-01-01, 2018-12-12

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

Lines changed: 103 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ create or replace table t2 (id int, s date, e date, period for apptime(s,e));
1212
insert t2 select * from t;
1313
create or replace table t3 (id int, s date, e date, period for apptime(s,e));
1414
insert t3 select * from t;
15+
create or replace table log_tbl(id int auto_increment primary key, log text) engine=myisam;
16+
create or replace procedure log(s text)
17+
insert into log_tbl(log) values(s);
18+
create trigger tr1upd_t1 before update on t1
19+
for each row call log(CONCAT('>UPD: ', old.id, ", ", old.s, ", ", old.e, ' -> ', new.id, ", ", new.s, ", ", new.e));
20+
create trigger tr2upd_t1 after update on t1
21+
for each row call log(CONCAT('<UPD: ', old.id, ", ", old.s, ", ", old.e, ' -> ', new.id, ", ", new.s, ", ", new.e));
22+
create trigger tr1del_t1 before delete on t1
23+
for each row call log(CONCAT('>DEL: ', old.id, ", ", old.s, ", ", old.e));
24+
create trigger tr2del_t1 after delete on t1
25+
for each row call log(CONCAT('<DEL: ', old.id, ", ", old.s, ", ", old.e));
26+
create trigger tr1ins_t1 before insert on t1
27+
for each row call log(CONCAT('>INS: ', new.id, ", ", new.s, ", ", new.e));
28+
create trigger tr2ins_t1 after insert on t1
29+
for each row call log(CONCAT('<INS: ', new.id, ", ", new.s, ", ", new.e));
1530
delete from t for portion of apptime from '2000-01-01' to '2018-01-01';
1631
delete from t1 for portion of APPTIME from '2000-01-01' to '2018-01-01';
1732
select * from t;
@@ -67,6 +82,21 @@ id log
6782
29 >DEL: 5, 2010-01-01, 2015-01-01
6883
30 <DEL: 5, 2010-01-01, 2015-01-01
6984
# INSERT trigger only also works
85+
create or replace table log_tbl(id int auto_increment primary key, log text) engine=myisam;
86+
create or replace procedure log(s text)
87+
insert into log_tbl(log) values(s);
88+
create trigger tr1upd_t2 before update on t2
89+
for each row call log(CONCAT('>UPD: ', old.id, ", ", old.s, ", ", old.e, ' -> ', new.id, ", ", new.s, ", ", new.e));
90+
create trigger tr2upd_t2 after update on t2
91+
for each row call log(CONCAT('<UPD: ', old.id, ", ", old.s, ", ", old.e, ' -> ', new.id, ", ", new.s, ", ", new.e));
92+
create trigger tr1del_t2 before delete on t2
93+
for each row call log(CONCAT('>DEL: ', old.id, ", ", old.s, ", ", old.e));
94+
create trigger tr2del_t2 after delete on t2
95+
for each row call log(CONCAT('<DEL: ', old.id, ", ", old.s, ", ", old.e));
96+
create trigger tr1ins_t2 before insert on t2
97+
for each row call log(CONCAT('>INS: ', new.id, ", ", new.s, ", ", new.e));
98+
create trigger tr2ins_t2 after insert on t2
99+
for each row call log(CONCAT('<INS: ', new.id, ", ", new.s, ", ", new.e));
70100
drop trigger tr1del_t2;
71101
drop trigger tr2del_t2;
72102
delete from t2 for portion of APPTIME from '2000-01-01' to '2018-01-01';
@@ -91,6 +121,21 @@ id log
91121
# removing BEFORE INSERT trigger enables internal substitution
92122
# DELETE+INSERT -> UPDATE, but without any side effects.
93123
# The optimization is disabled for non-transactional engines
124+
create or replace table log_tbl(id int auto_increment primary key, log text) engine=myisam;
125+
create or replace procedure log(s text)
126+
insert into log_tbl(log) values(s);
127+
create trigger tr1upd_t3 before update on t3
128+
for each row call log(CONCAT('>UPD: ', old.s, ", ", old.e, ' -> ', new.s, ", ", new.e));
129+
create trigger tr2upd_t3 after update on t3
130+
for each row call log(CONCAT('<UPD: ', old.s, ", ", old.e, ' -> ', new.s, ", ", new.e));
131+
create trigger tr1del_t3 before delete on t3
132+
for each row call log(CONCAT('>DEL: ', old.s, ", ", old.e));
133+
create trigger tr2del_t3 after delete on t3
134+
for each row call log(CONCAT('<DEL: ', old.s, ", ", old.e));
135+
create trigger tr1ins_t3 before insert on t3
136+
for each row call log(CONCAT('>INS: ', new.s, ", ", new.e));
137+
create trigger tr2ins_t3 after insert on t3
138+
for each row call log(CONCAT('<INS: ', new.s, ", ", new.e));
94139
drop trigger tr1ins_t3;
95140
delete from t3 for portion of APPTIME from '2000-01-01' to '2018-01-01';
96141
select * from log_tbl order by id;
@@ -167,6 +212,21 @@ id s e
167212
truncate t;
168213
# same for trigger case
169214
insert into t values (default, '1999-01-01', '2018-12-12');
215+
create or replace table log_tbl(id int auto_increment primary key, log text) engine=myisam;
216+
create or replace procedure log(s text)
217+
insert into log_tbl(log) values(s);
218+
create trigger tr1upd_t before update on t
219+
for each row call log(CONCAT('>UPD: ', old.s, ", ", old.e, ' -> ', new.s, ", ", new.e));
220+
create trigger tr2upd_t after update on t
221+
for each row call log(CONCAT('<UPD: ', old.s, ", ", old.e, ' -> ', new.s, ", ", new.e));
222+
create trigger tr1del_t before delete on t
223+
for each row call log(CONCAT('>DEL: ', old.s, ", ", old.e));
224+
create trigger tr2del_t after delete on t
225+
for each row call log(CONCAT('<DEL: ', old.s, ", ", old.e));
226+
create trigger tr1ins_t before insert on t
227+
for each row call log(CONCAT('>INS: ', new.s, ", ", new.e));
228+
create trigger tr2ins_t after insert on t
229+
for each row call log(CONCAT('<INS: ', new.s, ", ", new.e));
170230
delete from t for portion of apptime from '2000-01-01' to '2018-01-01';
171231
select * from t;
172232
id s e
@@ -196,6 +256,21 @@ s e xs xe
196256
truncate t;
197257
# same for trigger case
198258
insert into t values('1999-01-01', '2018-12-12', default, default);
259+
create or replace table log_tbl(id int auto_increment primary key, log text) engine=myisam;
260+
create or replace procedure log(s text)
261+
insert into log_tbl(log) values(s);
262+
create trigger tr1upd_t before update on t
263+
for each row call log(CONCAT('>UPD: ', old.s, ", ", old.e, ' -> ', new.s, ", ", new.e));
264+
create trigger tr2upd_t after update on t
265+
for each row call log(CONCAT('<UPD: ', old.s, ", ", old.e, ' -> ', new.s, ", ", new.e));
266+
create trigger tr1del_t before delete on t
267+
for each row call log(CONCAT('>DEL: ', old.s, ", ", old.e));
268+
create trigger tr2del_t after delete on t
269+
for each row call log(CONCAT('<DEL: ', old.s, ", ", old.e));
270+
create trigger tr1ins_t before insert on t
271+
for each row call log(CONCAT('>INS: ', new.s, ", ", new.e));
272+
create trigger tr2ins_t after insert on t
273+
for each row call log(CONCAT('<INS: ', new.s, ", ", new.e));
199274
delete from t for portion of apptime from '2000-01-01' to '2018-01-01';
200275
select * from t;
201276
s e xs xe
@@ -219,11 +294,39 @@ s date, e date, period for apptime(s,e));
219294
insert into t values(127, '1999-01-01', '2018-12-12');
220295
delete from t for portion of apptime from '2000-01-01' to '2018-01-01';
221296
ERROR 22003: Out of range value for column 'id' at row 1
297+
select * from t;
298+
id s e
299+
127 1999-01-01 2018-12-12
222300
# same for trigger case
301+
create or replace table log_tbl(id int auto_increment primary key, log text) engine=myisam;
302+
create or replace procedure log(s text)
303+
insert into log_tbl(log) values(s);
304+
create trigger tr1upd_t before update on t
305+
for each row call log(CONCAT('>UPD: ', old.s, ", ", old.e, ' -> ', new.s, ", ", new.e));
306+
create trigger tr2upd_t after update on t
307+
for each row call log(CONCAT('<UPD: ', old.s, ", ", old.e, ' -> ', new.s, ", ", new.e));
308+
create trigger tr1del_t before delete on t
309+
for each row call log(CONCAT('>DEL: ', old.s, ", ", old.e));
310+
create trigger tr2del_t after delete on t
311+
for each row call log(CONCAT('<DEL: ', old.s, ", ", old.e));
312+
create trigger tr1ins_t before insert on t
313+
for each row call log(CONCAT('>INS: ', new.s, ", ", new.e));
314+
create trigger tr2ins_t after insert on t
315+
for each row call log(CONCAT('<INS: ', new.s, ", ", new.e));
223316
# negotiate side effects of non-transactional MyISAM engine
224317
replace into t values(127, '1999-01-01', '2018-12-12');
318+
select * from t;
319+
id s e
320+
127 1999-01-01 2018-12-12
321+
truncate table log_tbl;
225322
delete from t for portion of apptime from '2000-01-01' to '2018-01-01';
226323
ERROR 22003: Out of range value for column 'id' at row 1
324+
select * from t;
325+
id s e
326+
127 1999-01-01 2018-12-12
327+
select * from log_tbl order by id;
328+
id log
329+
1 >DEL: 1999-01-01, 2018-12-12
227330
# custom constraint for period fields
228331
create or replace table t(id int, s date, e date, period for apptime(s,e),
229332
constraint dist2days check (datediff(e, s) >= 2));
@@ -246,54 +349,4 @@ id s e datediff(e, s)
246349
1 1999-01-01 1999-01-03 2
247350
1 2018-12-10 2018-12-12 2
248351
2 1999-01-01 1999-01-03 2
249-
# system_time columns are updated
250-
create or replace table t (
251-
s date, e date,
252-
row_start SYS_TYPE as row start invisible,
253-
row_end SYS_TYPE as row end invisible,
254-
period for apptime(s, e),
255-
period for system_time (row_start, row_end)) with system versioning;
256-
insert into t values('1999-01-01', '2018-12-12'),
257-
('1999-01-01', '1999-12-12');
258-
select row_start into @ins_time from t limit 1;
259-
select * from t order by s, e;
260-
s e
261-
1999-01-01 1999-12-12
262-
1999-01-01 2018-12-12
263-
delete from t for portion of apptime from '2000-01-01' to '2018-01-01';
264-
select *, if(row_start = @ins_time, "OLD", "NEW"), check_row(row_start, row_end)
265-
from t for system_time all
266-
order by s, e, row_start;
267-
s e if(row_start = @ins_time, "OLD", "NEW") check_row(row_start, row_end)
268-
1999-01-01 1999-12-12 OLD CURRENT ROW
269-
1999-01-01 2000-01-01 NEW CURRENT ROW
270-
1999-01-01 2018-12-12 OLD HISTORICAL ROW
271-
2018-01-01 2018-12-12 NEW CURRENT ROW
272-
# same for trigger case
273-
delete from t;
274-
delete history from t;
275-
insert into t values('1999-01-01', '2018-12-12'),
276-
('1999-01-01', '1999-12-12');
277-
select row_start into @ins_time from t limit 1;
278-
select * from t order by s, e;
279-
s e
280-
1999-01-01 1999-12-12
281-
1999-01-01 2018-12-12
282-
delete from t for portion of apptime from '2000-01-01' to '2018-01-01';
283-
select *, if(row_start = @ins_time, "OLD", "NEW"), check_row(row_start, row_end)
284-
from t for system_time all
285-
order by s, e, row_start;
286-
s e if(row_start = @ins_time, "OLD", "NEW") check_row(row_start, row_end)
287-
1999-01-01 1999-12-12 OLD CURRENT ROW
288-
1999-01-01 2000-01-01 NEW CURRENT ROW
289-
1999-01-01 2018-12-12 OLD HISTORICAL ROW
290-
2018-01-01 2018-12-12 NEW CURRENT ROW
291-
select * from log_tbl order by id;
292-
id log
293-
1 >DEL: 1999-01-01, 2018-12-12
294-
2 >INS: 1999-01-01, 2000-01-01
295-
3 <INS: 1999-01-01, 2000-01-01
296-
4 >INS: 2018-01-01, 2018-12-12
297-
5 <INS: 2018-01-01, 2018-12-12
298-
6 <DEL: 1999-01-01, 2018-12-12
299352
create or replace database test;

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

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ id s e
3030
8 2000-01-01 2018-01-01
3131
9 2000-01-01 2015-01-01
3232
# Check triggers
33+
create or replace table log_tbl(id int auto_increment primary key, log text) engine=myisam;
34+
create or replace procedure log(s text)
35+
insert into log_tbl(log) values(s);
36+
create trigger tr1upd_t1 before update on t1
37+
for each row call log(CONCAT('>UPD: ', old.id, ", ", old.s, ", ", old.e, ' -> ', new.id, ", ", new.s, ", ", new.e));
38+
create trigger tr2upd_t1 after update on t1
39+
for each row call log(CONCAT('<UPD: ', old.id, ", ", old.s, ", ", old.e, ' -> ', new.id, ", ", new.s, ", ", new.e));
40+
create trigger tr1del_t1 before delete on t1
41+
for each row call log(CONCAT('>DEL: ', old.id, ", ", old.s, ", ", old.e));
42+
create trigger tr2del_t1 after delete on t1
43+
for each row call log(CONCAT('<DEL: ', old.id, ", ", old.s, ", ", old.e));
44+
create trigger tr1ins_t1 before insert on t1
45+
for each row call log(CONCAT('>INS: ', new.id, ", ", new.s, ", ", new.e));
46+
create trigger tr2ins_t1 after insert on t1
47+
for each row call log(CONCAT('<INS: ', new.id, ", ", new.s, ", ", new.e));
3348
update t1 for portion of apptime from '2000-01-01' to '2018-01-01'
3449
set id=id + 6;
3550
select * from t1;
@@ -82,6 +97,21 @@ id log
8297
29 >UPD: 5, 2010-01-01, 2015-01-01 -> 11, 2010-01-01, 2015-01-01
8398
30 <UPD: 5, 2010-01-01, 2015-01-01 -> 11, 2010-01-01, 2015-01-01
8499
# INSERT trigger only also works
100+
create or replace table log_tbl(id int auto_increment primary key, log text) engine=myisam;
101+
create or replace procedure log(s text)
102+
insert into log_tbl(log) values(s);
103+
create trigger tr1upd_t2 before update on t2
104+
for each row call log(CONCAT('>UPD: ', old.id, ", ", old.s, ", ", old.e, ' -> ', new.id, ", ", new.s, ", ", new.e));
105+
create trigger tr2upd_t2 after update on t2
106+
for each row call log(CONCAT('<UPD: ', old.id, ", ", old.s, ", ", old.e, ' -> ', new.id, ", ", new.s, ", ", new.e));
107+
create trigger tr1del_t2 before delete on t2
108+
for each row call log(CONCAT('>DEL: ', old.id, ", ", old.s, ", ", old.e));
109+
create trigger tr2del_t2 after delete on t2
110+
for each row call log(CONCAT('<DEL: ', old.id, ", ", old.s, ", ", old.e));
111+
create trigger tr1ins_t2 before insert on t2
112+
for each row call log(CONCAT('>INS: ', new.id, ", ", new.s, ", ", new.e));
113+
create trigger tr2ins_t2 after insert on t2
114+
for each row call log(CONCAT('<INS: ', new.id, ", ", new.s, ", ", new.e));
85115
drop trigger tr1upd_t2;
86116
drop trigger tr2upd_t2;
87117
update t2 for portion of apptime from '2000-01-01' to '2018-01-01'
@@ -225,27 +255,4 @@ x s e xs xe xs=s and xe=e
225255
1 1999-01-01 2000-01-01 1999-01-01 2000-01-01 1
226256
1 2018-01-01 2018-12-12 2018-01-01 2018-12-12 1
227257
6 2000-01-01 2018-01-01 2000-01-01 2018-01-01 1
228-
# system_time columns are updated
229-
create or replace table t (x int, s date, e date,
230-
row_start SYS_TYPE as row start invisible,
231-
row_end SYS_TYPE as row end invisible,
232-
period for apptime(s, e),
233-
period for system_time(row_start, row_end)) with system versioning;
234-
insert into t values(1, '1999-01-01', '2018-12-12'),
235-
(2, '1999-01-01', '1999-12-12');
236-
select row_start into @ins_time from t limit 1;
237-
select * from t;
238-
x s e
239-
1 1999-01-01 2018-12-12
240-
2 1999-01-01 1999-12-12
241-
update t for portion of apptime from '2000-01-01' to '2018-01-01' set x= x + 5;
242-
select *, if(row_start = @ins_time, "OLD", "NEW"), check_row(row_start, row_end)
243-
from t for system_time all
244-
order by x, s, e, row_start;
245-
x s e if(row_start = @ins_time, "OLD", "NEW") check_row(row_start, row_end)
246-
1 1999-01-01 2000-01-01 NEW CURRENT ROW
247-
1 1999-01-01 2018-12-12 OLD HISTORICAL ROW
248-
1 2018-01-01 2018-12-12 NEW CURRENT ROW
249-
2 1999-01-01 1999-12-12 OLD CURRENT ROW
250-
6 2000-01-01 2018-01-01 NEW CURRENT ROW
251258
create or replace database test;

0 commit comments

Comments
 (0)