~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/suite/funcs_1/r/falcon_trig_08.result

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
USE test;
 
2
drop table if exists tb3 ;
 
3
create table tb3 (
 
4
f118 char not null DEFAULT 'a', 
 
5
f119 char binary not null DEFAULT b'101', 
 
6
f120 char ascii not null DEFAULT b'101', 
 
7
f121 tinytext, 
 
8
f122 text, 
 
9
f123 mediumtext, 
 
10
f124 longtext unicode, 
 
11
f125 tinyblob, 
 
12
f126 blob, 
 
13
f127 mediumblob, 
 
14
f128 longblob, 
 
15
f129 binary not null DEFAULT b'101', 
 
16
f130 tinyint not null DEFAULT 99, 
 
17
f131 tinyint unsigned not null DEFAULT 99, 
 
18
f132 tinyint zerofill not null DEFAULT 99, 
 
19
f133 tinyint unsigned zerofill not null DEFAULT 99, 
 
20
f134 smallint not null DEFAULT 999, 
 
21
f135 smallint unsigned not null DEFAULT 999, 
 
22
f136 smallint zerofill not null DEFAULT 999,  
 
23
f137 smallint unsigned zerofill not null DEFAULT 999, 
 
24
f138 mediumint not null DEFAULT 9999, 
 
25
f139 mediumint unsigned not null DEFAULT 9999, 
 
26
f140 mediumint zerofill not null DEFAULT 9999, 
 
27
f141 mediumint unsigned zerofill not null DEFAULT 9999, 
 
28
f142 int not null DEFAULT 99999, 
 
29
f143 int unsigned not null DEFAULT 99999, 
 
30
f144 int zerofill not null DEFAULT 99999, 
 
31
f145 int unsigned zerofill not null DEFAULT 99999, 
 
32
f146 bigint not null DEFAULT 999999, 
 
33
f147 bigint unsigned not null DEFAULT 999999, 
 
34
f148 bigint zerofill not null DEFAULT 999999, 
 
35
f149 bigint unsigned zerofill not null DEFAULT 999999, 
 
36
f150 decimal not null DEFAULT 999.999, 
 
37
f151 decimal unsigned not null DEFAULT 999.17, 
 
38
f152 decimal zerofill not null DEFAULT 999.999, 
 
39
f153 decimal unsigned zerofill, 
 
40
f154 decimal (0), 
 
41
f155 decimal (64), 
 
42
f156 decimal (0) unsigned, 
 
43
f157 decimal (64) unsigned, 
 
44
f158 decimal (0) zerofill, 
 
45
f159 decimal (64) zerofill, 
 
46
f160 decimal (0) unsigned zerofill, 
 
47
f161 decimal (64) unsigned zerofill, 
 
48
f162 decimal (0,0), 
 
49
f163 decimal (63,30), 
 
50
f164 decimal (0,0) unsigned, 
 
51
f165 decimal (63,30) unsigned, 
 
52
f166 decimal (0,0) zerofill, 
 
53
f167 decimal (63,30) zerofill, 
 
54
f168 decimal (0,0) unsigned zerofill, 
 
55
f169 decimal (63,30) unsigned zerofill, 
 
56
f170 numeric, 
 
57
f171 numeric unsigned, 
 
58
f172 numeric zerofill, 
 
59
f173 numeric unsigned zerofill, 
 
60
f174 numeric (0), 
 
61
f175 numeric (64) 
 
62
) engine = falcon;
 
63
Warnings:
 
64
Note    1265    Data truncated for column 'f150' at row 1
 
65
Note    1265    Data truncated for column 'f151' at row 1
 
66
Note    1265    Data truncated for column 'f152' at row 1
 
67
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/innodb_tb3.txt' into table tb3 ;
 
68
 
 
69
Testcase: 3.5:
 
70
--------------
 
71
create User test_general@localhost;
 
72
set password for test_general@localhost = password('PWD');
 
73
revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost;
 
74
create User test_super@localhost;
 
75
set password for test_super@localhost = password('PWD');
 
76
grant ALL on *.* to test_super@localhost with grant OPTION;
 
77
connect(localhost,test_general,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
78
connect(localhost,test_super,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
79
 
 
80
Testcase 3.5.8.1: (implied in previous tests)
 
81
---------------------------------------------
 
82
 
 
83
Testcase 3.5.8.2: (implied in previous tests)
 
84
---------------------------------------------
 
85
 
 
86
Testcase 3.5.8.3/4:
 
87
-------------------
 
88
create database db_test;
 
89
grant SELECT, INSERT, UPDATE, DELETE on db_test.* to test_general;
 
90
grant LOCK TABLES on db_test.* to test_general;
 
91
Use db_test;
 
92
create table t1_i ( 
 
93
i120 char ascii not null DEFAULT b'101',
 
94
i136 smallint zerofill not null DEFAULT 999,
 
95
i144 int zerofill not null DEFAULT 99999,
 
96
i163 decimal (63,30)) engine=falcon;
 
97
create table t1_u ( 
 
98
u120 char ascii not null DEFAULT b'101',
 
99
u136 smallint zerofill not null DEFAULT 999,
 
100
u144 int zerofill not null DEFAULT 99999,
 
101
u163 decimal (63,30)) engine=falcon;
 
102
create table t1_d ( 
 
103
d120 char ascii not null DEFAULT b'101',
 
104
d136 smallint zerofill not null DEFAULT 999,
 
105
d144 int zerofill not null DEFAULT 99999,
 
106
d163 decimal (63,30)) engine=falcon;
 
107
Insert into t1_u values ('a',111,99999,999.99);
 
108
Insert into t1_u values ('b',222,99999,999.99);
 
109
Insert into t1_u values ('c',333,99999,999.99);
 
110
Insert into t1_u values ('d',222,99999,999.99);
 
111
Insert into t1_u values ('e',222,99999,999.99);
 
112
Insert into t1_u values ('f',333,99999,999.99);
 
113
Insert into t1_d values ('a',111,99999,999.99);
 
114
Insert into t1_d values ('b',222,99999,999.99);
 
115
Insert into t1_d values ('c',333,99999,999.99);
 
116
Insert into t1_d values ('d',444,99999,999.99);
 
117
Insert into t1_d values ('e',222,99999,999.99);
 
118
Insert into t1_d values ('f',222,99999,999.99);
 
119
 
 
120
3.5.8.4 - multiple SQL
 
121
----------------------
 
122
use test;
 
123
Create trigger trg1 AFTER INSERT on tb3 for each row
 
124
BEGIN
 
125
insert into db_test.t1_i 
 
126
values (new.f120, new.f136, new.f144, new.f163);
 
127
update db_test.t1_u 
 
128
set u144=new.f144, u163=new.f163
 
129
where u136=new.f136; 
 
130
delete from db_test.t1_d where d136= new.f136;
 
131
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u 
 
132
where u136= new.f136; 
 
133
END//
 
134
Use test;
 
135
set @test_var=0;
 
136
Insert into tb3 (f120, f122, f136, f144, f163) 
 
137
values ('1', 'Test 3.5.8.4', 222, 23456, 1.05);
 
138
Select f120, f122, f136, f144, f163 from tb3 where f122= 'Test 3.5.8.4';
 
139
f120    f122    f136    f144    f163
 
140
1       Test 3.5.8.4    00222   0000023456      1.050000000000000000000000000000
 
141
select * from db_test.t1_i;
 
142
i120    i136    i144    i163
 
143
1       00222   0000023456      1.050000000000000000000000000000
 
144
select * from db_test.t1_u;
 
145
u120    u136    u144    u163
 
146
a       00111   0000099999      999.990000000000000000000000000000
 
147
b       00222   0000023456      1.050000000000000000000000000000
 
148
c       00333   0000099999      999.990000000000000000000000000000
 
149
d       00222   0000023456      1.050000000000000000000000000000
 
150
e       00222   0000023456      1.050000000000000000000000000000
 
151
f       00333   0000099999      999.990000000000000000000000000000
 
152
select * from db_test.t1_d;
 
153
d120    d136    d144    d163
 
154
a       00111   0000099999      999.990000000000000000000000000000
 
155
c       00333   0000099999      999.990000000000000000000000000000
 
156
d       00444   0000099999      999.990000000000000000000000000000
 
157
select @test_var;
 
158
@test_var
 
159
3.150000000000000000000000000000
 
160
 
 
161
3.5.8.4 - single SQL - insert
 
162
-----------------------------
 
163
Create trigger trg2 BEFORE UPDATE on tb3 for each row
 
164
BEGIN
 
165
insert into db_test.t1_i 
 
166
values (new.f120, new.f136, new.f144, new.f163);
 
167
END//
 
168
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
 
169
f120    f122    f136    f144    f163
 
170
1       Test 3.5.8.4    00222   0000023456      1.050000000000000000000000000000
 
171
select * from db_test.t1_i order by i120;
 
172
i120    i136    i144    i163
 
173
1       00222   0000023456      1.050000000000000000000000000000
 
174
update tb3 set f120='I', f122='Test 3.5.8.4-Single Insert'
 
175
                 where f122='Test 3.5.8.4';
 
176
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
 
177
f120    f122    f136    f144    f163
 
178
I       Test 3.5.8.4-Single Insert      00222   0000023456      1.050000000000000000000000000000
 
179
select * from db_test.t1_i order by i120;
 
180
i120    i136    i144    i163
 
181
1       00222   0000023456      1.050000000000000000000000000000
 
182
I       00222   0000023456      1.050000000000000000000000000000
 
183
 
 
184
3.5.8.4 - single SQL - update
 
185
-----------------------------
 
186
drop trigger trg2;
 
187
Create trigger trg3 BEFORE UPDATE on tb3 for each row
 
188
update db_test.t1_u 
 
189
set u120=new.f120
 
190
where u136=new.f136;
 
191
update tb3 set f120='U', f122='Test 3.5.8.4-Single Update'
 
192
                 where f122='Test 3.5.8.4-Single Insert';
 
193
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
 
194
f120    f122    f136    f144    f163
 
195
U       Test 3.5.8.4-Single Update      00222   0000023456      1.050000000000000000000000000000
 
196
select * from db_test.t1_u order by u120;
 
197
u120    u136    u144    u163
 
198
a       00111   0000099999      999.990000000000000000000000000000
 
199
c       00333   0000099999      999.990000000000000000000000000000
 
200
f       00333   0000099999      999.990000000000000000000000000000
 
201
U       00222   0000023456      1.050000000000000000000000000000
 
202
U       00222   0000023456      1.050000000000000000000000000000
 
203
U       00222   0000023456      1.050000000000000000000000000000
 
204
 
 
205
3.5.8.3/4 - single SQL - delete
 
206
-------------------------------
 
207
drop trigger trg3;
 
208
Create trigger trg4 AFTER UPDATE on tb3 for each row
 
209
delete from db_test.t1_d where d136= new.f136;
 
210
update tb3 set f120='D', f136=444, 
 
211
f122='Test 3.5.8.4-Single Delete'
 
212
                 where f122='Test 3.5.8.4-Single Update';
 
213
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
 
214
f120    f122    f136    f144    f163
 
215
D       Test 3.5.8.4-Single Delete      00444   0000023456      1.050000000000000000000000000000
 
216
select * from db_test.t1_d order by d120;
 
217
d120    d136    d144    d163
 
218
a       00111   0000099999      999.990000000000000000000000000000
 
219
c       00333   0000099999      999.990000000000000000000000000000
 
220
 
 
221
3.5.8.3/4 - single SQL - select
 
222
-------------------------------
 
223
drop trigger trg4;
 
224
Create trigger trg5 AFTER UPDATE on tb3 for each row
 
225
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u 
 
226
where u136= new.f136;
 
227
set @test_var=0;
 
228
update tb3 set f120='S', f136=111, 
 
229
f122='Test 3.5.8.4-Single Select'
 
230
                 where f122='Test 3.5.8.4-Single Delete';
 
231
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
 
232
f120    f122    f136    f144    f163
 
233
S       Test 3.5.8.4-Single Select      00111   0000023456      1.050000000000000000000000000000
 
234
select @test_var;
 
235
@test_var
 
236
999.990000000000000000000000000000
 
237
drop trigger trg1;
 
238
drop trigger trg5;
 
239
drop database if exists db_test;
 
240
delete from tb3 where f122 like 'Test 3.5.8.4%';
 
241
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
 
242
 
 
243
Testcase 3.5.8.5 (IF):
 
244
----------------------
 
245
create trigger trg2 before insert on tb3 for each row
 
246
BEGIN
 
247
IF new.f120='1' then
 
248
set @test_var='one', new.f120='2';
 
249
ELSEIF new.f120='2' then
 
250
set @test_var='two', new.f120='3';
 
251
ELSEIF new.f120='3' then
 
252
set @test_var='three', new.f120='4';
 
253
END IF;
 
254
IF (new.f120='4') and (new.f136=10) then
 
255
set @test_var2='2nd if', new.f120='d';
 
256
ELSE 
 
257
set @test_var2='2nd else', new.f120='D';
 
258
END IF;
 
259
END//
 
260
set @test_var='Empty', @test_var2=0;
 
261
Insert into tb3 (f120, f122, f136) values ('1', 'Test 3.5.8.5-if', 101);
 
262
select f120, f122, f136, @test_var, @test_var2 
 
263
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
 
264
f120    f122    f136    @test_var       @test_var2
 
265
D       Test 3.5.8.5-if 00101   one     2nd else
 
266
Insert into tb3 (f120, f122, f136) values ('2', 'Test 3.5.8.5-if', 102);
 
267
select f120, f122, f136, @test_var, @test_var2 
 
268
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
 
269
f120    f122    f136    @test_var       @test_var2
 
270
D       Test 3.5.8.5-if 00101   two     2nd else
 
271
D       Test 3.5.8.5-if 00102   two     2nd else
 
272
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 10);
 
273
select f120, f122, f136, @test_var, @test_var2 
 
274
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
 
275
f120    f122    f136    @test_var       @test_var2
 
276
d       Test 3.5.8.5-if 00010   three   2nd if
 
277
D       Test 3.5.8.5-if 00101   three   2nd if
 
278
D       Test 3.5.8.5-if 00102   three   2nd if
 
279
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 103);
 
280
select f120, f122, f136, @test_var, @test_var2 
 
281
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
 
282
f120    f122    f136    @test_var       @test_var2
 
283
d       Test 3.5.8.5-if 00010   three   2nd else
 
284
D       Test 3.5.8.5-if 00101   three   2nd else
 
285
D       Test 3.5.8.5-if 00102   three   2nd else
 
286
D       Test 3.5.8.5-if 00103   three   2nd else
 
287
create trigger trg3 before update on tb3 for each row
 
288
BEGIN
 
289
ELSEIF new.f120='2' then
 
290
END IF;
 
291
END//
 
292
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ELSEIF new.f120='2' then
 
293
END IF;
 
294
END' at line 3
 
295
drop trigger trg3//
 
296
create trigger trg4 before update on tb3 for each row
 
297
BEGIN
 
298
IF (new.f120='4') and (new.f136=10) then
 
299
set @test_var2='2nd if', new.f120='d';
 
300
ELSE 
 
301
set @test_var2='2nd else', new.f120='D';
 
302
END//
 
303
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7
 
304
drop trigger trg4;
 
305
drop trigger trg2;
 
306
delete from tb3 where f121='Test 3.5.8.5-if';
 
307
 
 
308
Testcase 3.5.8.5-case:
 
309
----------------------
 
310
create trigger trg3 before insert on tb3 for each row
 
311
BEGIN
 
312
SET new.f120=char(ascii(new.f120)-32);
 
313
CASE
 
314
when new.f136<100 then set new.f136=new.f136+120;
 
315
when new.f136<10 then set new.f144=777;
 
316
when new.f136>100 then set new.f120=new.f136-1;
 
317
END case;
 
318
CASE
 
319
when new.f136=200 then set @test_var=CONCAT(new.f120, '=');
 
320
ELSE set @test_var=concat(new.f120, '*');
 
321
END case;
 
322
CASE new.f144
 
323
when 1 then set @test_var=concat(@test_var, 'one');
 
324
when 2 then set @test_var=concat(@test_var, 'two');
 
325
when 3 then set @test_var=concat(@test_var, 'three');
 
326
when 4 then set @test_var=concat(@test_var, 'four');
 
327
when 5 then set @test_var=concat(@test_var, 'five');
 
328
when 6 then set @test_var=concat(@test_var, 'six');
 
329
when 7 then set @test_var=concat(@test_var, 'seven');
 
330
when 8 then set @test_var=concat(@test_var, 'eight');
 
331
when 9 then set @test_var=concat(@test_var, 'nine');
 
332
when 10 then set @test_var=concat(@test_var, 'ten');
 
333
when 11 then set @test_var=concat(@test_var, 'eleven');
 
334
when 12 then set @test_var=concat(@test_var, 'twelve');
 
335
when 13 then set @test_var=concat(@test_var, 'thirteen');
 
336
when 14 then set @test_var=concat(@test_var, 'fourteen');
 
337
when 15 then set @test_var=concat(@test_var, 'fifteen');
 
338
ELSE set @test_var=CONCAT(new.f120, '*', new.f144);
 
339
END case;
 
340
END//
 
341
set @test_var='Empty';
 
342
Insert into tb3 (f120, f122, f136, f144) 
 
343
values ('a', 'Test 3.5.8.5-case', 5, 7);
 
344
select f120, f122, f136, f144, @test_var 
 
345
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 
346
f120    f122    f136    f144    @test_var
 
347
A       Test 3.5.8.5-case       00125   0000000007      A*seven
 
348
Insert into tb3 (f120, f122, f136, f144) 
 
349
values ('b', 'Test 3.5.8.5-case', 71,16);
 
350
select f120, f122, f136, f144, @test_var 
 
351
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 
352
f120    f122    f136    f144    @test_var
 
353
A       Test 3.5.8.5-case       00125   0000000007      B*0000000016
 
354
B       Test 3.5.8.5-case       00191   0000000016      B*0000000016
 
355
Insert into tb3 (f120, f122, f136, f144) 
 
356
values ('c', 'Test 3.5.8.5-case', 80,1);
 
357
select f120, f122, f136, f144, @test_var 
 
358
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 
359
f120    f122    f136    f144    @test_var
 
360
A       Test 3.5.8.5-case       00125   0000000007      C=one
 
361
B       Test 3.5.8.5-case       00191   0000000016      C=one
 
362
C       Test 3.5.8.5-case       00200   0000000001      C=one
 
363
Insert into tb3 (f120, f122, f136) 
 
364
values ('d', 'Test 3.5.8.5-case', 152);
 
365
Warnings:
 
366
Warning 1265    Data truncated for column 'f120' at row 1
 
367
select f120, f122, f136, f144, @test_var 
 
368
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 
369
f120    f122    f136    f144    @test_var
 
370
1       Test 3.5.8.5-case       00152   0000099999      1*0000099999
 
371
A       Test 3.5.8.5-case       00125   0000000007      1*0000099999
 
372
B       Test 3.5.8.5-case       00191   0000000016      1*0000099999
 
373
C       Test 3.5.8.5-case       00200   0000000001      1*0000099999
 
374
Insert into tb3 (f120, f122, f136, f144) 
 
375
values ('e', 'Test 3.5.8.5-case', 200, 8);
 
376
Warnings:
 
377
Warning 1265    Data truncated for column 'f120' at row 1
 
378
select f120, f122, f136, f144, @test_var 
 
379
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 
380
f120    f122    f136    f144    @test_var
 
381
1       Test 3.5.8.5-case       00152   0000099999      1=eight
 
382
1       Test 3.5.8.5-case       00200   0000000008      1=eight
 
383
A       Test 3.5.8.5-case       00125   0000000007      1=eight
 
384
B       Test 3.5.8.5-case       00191   0000000016      1=eight
 
385
C       Test 3.5.8.5-case       00200   0000000001      1=eight
 
386
Insert into tb3 (f120, f122, f136, f144) 
 
387
values ('f', 'Test 3.5.8.5-case', 100, 8);
 
388
select f120, f122, f136, f144, @test_var 
 
389
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 
390
f120    f122    f136    f144    @test_var
 
391
1       Test 3.5.8.5-case       00152   0000099999      1=eight
 
392
1       Test 3.5.8.5-case       00200   0000000008      1=eight
 
393
A       Test 3.5.8.5-case       00125   0000000007      1=eight
 
394
B       Test 3.5.8.5-case       00191   0000000016      1=eight
 
395
C       Test 3.5.8.5-case       00200   0000000001      1=eight
 
396
create trigger trg3a before update on tb3 for each row
 
397
BEGIN
 
398
CASE
 
399
when new.f136<100 then set new.f120='p';
 
400
END//
 
401
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5
 
402
drop trigger trg3a;
 
403
drop trigger trg3;
 
404
delete from tb3 where f121='Test 3.5.8.5-case';
 
405
 
 
406
Testcase 3.5.8.5-loop/leave:
 
407
----------------------------
 
408
Create trigger trg4 after insert on tb3 for each row
 
409
BEGIN 
 
410
set @counter=0, @flag='Initial';
 
411
Label1: loop 
 
412
if new.f136<new.f144 then
 
413
set @counter='Nothing to loop';
 
414
leave Label1; 
 
415
else
 
416
set @counter=@counter+1;
 
417
if new.f136=new.f144+@counter then
 
418
set @counter=concat(@counter, ' loops');
 
419
leave Label1;
 
420
end if; 
 
421
end if; 
 
422
iterate label1; 
 
423
set @flag='Final';
 
424
END loop Label1; 
 
425
END//
 
426
Insert into tb3 (f122, f136, f144) 
 
427
values ('Test 3.5.8.5-loop', 2, 8);
 
428
select @counter, @flag;
 
429
@counter        @flag
 
430
Nothing to loop Initial
 
431
Insert into tb3 (f122, f136, f144) 
 
432
values ('Test 3.5.8.5-loop', 11, 8);
 
433
select @counter, @flag;
 
434
@counter        @flag
 
435
3 loops Initial
 
436
Create trigger trg4_2 after update on tb3 for each row
 
437
BEGIN 
 
438
Label1: loop 
 
439
set @counter=@counter+1;
 
440
END;  
 
441
END//
 
442
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';  
 
443
END' at line 5
 
444
drop trigger trg4_2;
 
445
drop trigger trg4;
 
446
delete from tb3 where f122='Test 3.5.8.5-loop';
 
447
 
 
448
Testcase 3.5.8.5-repeat:
 
449
------------------------
 
450
Create trigger trg6 after insert on tb3 for each row
 
451
BEGIN
 
452
rp_label: REPEAT 
 
453
SET @counter1 = @counter1 + 1; 
 
454
IF (@counter1 MOD 2 = 0) THEN ITERATE rp_label;         
 
455
END IF;
 
456
SET @counter2 = @counter2 + 1; 
 
457
UNTIL @counter1> new.f136 END REPEAT rp_label;
 
458
END//
 
459
set @counter1= 0, @counter2= 0;
 
460
Insert into tb3 (f122, f136) 
 
461
values ('Test 3.5.8.5-repeat', 13);
 
462
select @counter1, @counter2;
 
463
@counter1       @counter2
 
464
15      8
 
465
Create trigger trg6_2 after update on tb3 for each row
 
466
BEGIN
 
467
REPEAT 
 
468
SET @counter2 = @counter2 + 1; 
 
469
END//
 
470
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 5
 
471
drop trigger trg6;
 
472
delete from tb3 where f122='Test 3.5.8.5-repeat';
 
473
 
 
474
Testcase 3.5.8.5-while:
 
475
-----------------------
 
476
Create trigger trg7 after insert on tb3 for each row
 
477
wl_label: WHILE @counter1 < new.f136 DO 
 
478
SET @counter1 = @counter1 + 1; 
 
479
IF (@counter1 MOD 2 = 0) THEN ITERATE wl_label;         
 
480
END IF;
 
481
SET @counter2 = @counter2 + 1; 
 
482
END WHILE wl_label//
 
483
set @counter1= 0, @counter2= 0;
 
484
Insert into tb3 (f122, f136) 
 
485
values ('Test 3.5.8.5-while', 7);
 
486
select @counter1, @counter2;
 
487
@counter1       @counter2
 
488
7       4
 
489
Create trigger trg7_2 after update on tb3 for each row
 
490
BEGIN
 
491
WHILE @counter1 < new.f136 
 
492
SET @counter1 = @counter1 + 1; 
 
493
END//
 
494
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @counter1 = @counter1 + 1; 
 
495
END' at line 4
 
496
delete from tb3 where f122='Test 3.5.8.5-while';
 
497
drop trigger trg7;
 
498
 
 
499
Testcase 3.5.8.6: (requirement void)
 
500
------------------------------------
 
501
CREATE PROCEDURE sp_01 () BEGIN set @v1=1; END//
 
502
CREATE TRIGGER trg8_1 BEFORE UPDATE ON tb3 FOR EACH ROW
 
503
BEGIN
 
504
CALL sp_01 ();
 
505
END//
 
506
Insert into tb3 (f120, f122, f136) values ('6', 'Test 3.5.8.6-insert', 101);
 
507
update tb3 set f120='S', f136=111,
 
508
f122='Test 3.5.8.6-tr8_1'
 
509
               where f122='Test 3.5.8.6-insert';
 
510
select f120, f122
 
511
from tb3 where f122  like 'Test 3.5.8.6%' order by f120;
 
512
f120    f122
 
513
S       Test 3.5.8.6-tr8_1
 
514
DROP TRIGGER trg8_1;
 
515
DROP PROCEDURE sp_01;
 
516
 
 
517
Testcase 3.5.8.7
 
518
----------------
 
519
Create trigger trg9_1 before update on tb3 for each row
 
520
BEGIN
 
521
Start transaction;
 
522
Set new.f120='U';
 
523
Commit;
 
524
END//
 
525
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
 
526
Create trigger trg9_2 before delete on tb3 for each row
 
527
BEGIN
 
528
Start transaction;
 
529
Set @var2=old.f120;
 
530
Rollback;
 
531
END//
 
532
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
 
533
drop user test_general@localhost;
 
534
drop user test_general;
 
535
drop user test_super@localhost;
 
536
DROP TABLE test.tb3;