memory_trig_08.result 18.6 KB
Newer Older
1 2 3
USE test;
drop table if exists tb3;
create table tb3 (
unknown's avatar
unknown committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
f118 char not null DEFAULT 'a',
f119 char binary not null DEFAULT b'101',
f120 char ascii not null DEFAULT b'101',
f121 char(50),
f122 char(50),
f129 binary not null DEFAULT b'101',
f130 tinyint not null DEFAULT 99,
f131 tinyint unsigned not null DEFAULT 99,
f132 tinyint zerofill not null DEFAULT 99,
f133 tinyint unsigned zerofill not null DEFAULT 99,
f134 smallint not null DEFAULT 999,
f135 smallint unsigned not null DEFAULT 999,
f136 smallint zerofill not null DEFAULT 999,
f137 smallint unsigned zerofill not null DEFAULT 999,
f138 mediumint not null DEFAULT 9999,
f139 mediumint unsigned not null DEFAULT 9999,
f140 mediumint zerofill not null DEFAULT 9999,
f141 mediumint unsigned zerofill not null DEFAULT 9999,
f142 int not null DEFAULT 99999,
f143 int unsigned not null DEFAULT 99999,
f144 int zerofill not null DEFAULT 99999,
f145 int unsigned zerofill not null DEFAULT 99999,
f146 bigint not null DEFAULT 999999,
f147 bigint unsigned not null DEFAULT 999999,
f148 bigint zerofill not null DEFAULT 999999,
f149 bigint unsigned zerofill not null DEFAULT 999999,
f150 decimal not null DEFAULT 999.999,
f151 decimal unsigned not null DEFAULT 999.17,
f152 decimal zerofill not null DEFAULT 999.999,
f153 decimal unsigned zerofill,
f154 decimal (0),
f155 decimal (64),
f156 decimal (0) unsigned,
f157 decimal (64) unsigned,
f158 decimal (0) zerofill,
f159 decimal (64) zerofill,
f160 decimal (0) unsigned zerofill,
f161 decimal (64) unsigned zerofill,
f162 decimal (0,0),
f163 decimal (63,30),
f164 decimal (0,0) unsigned,
f165 decimal (63,30) unsigned,
f166 decimal (0,0) zerofill,
f167 decimal (63,30) zerofill,
f168 decimal (0,0) unsigned zerofill,
f169 decimal (63,30) unsigned zerofill,
f170 numeric,
f171 numeric unsigned,
f172 numeric zerofill,
f173 numeric unsigned zerofill,
f174 numeric (0),
f175 numeric (64)
56 57 58 59 60
) engine = memory;
Warnings:
Note	1265	Data truncated for column 'f150' at row 1
Note	1265	Data truncated for column 'f151' at row 1
Note	1265	Data truncated for column 'f152' at row 1
unknown's avatar
unknown committed
61 62
load data infile '<MYSQLTEST_VARDIR>/std_data_ln/funcs_1/memory_tb3.txt'
into table tb3;
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

Testcase: 3.5:
--------------
create User test_general@localhost;
set password for test_general@localhost = password('PWD');
revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost;
create User test_super@localhost;
set password for test_super@localhost = password('PWD');
grant ALL on *.* to test_super@localhost with grant OPTION;
connect(localhost,test_general,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_super,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);

Testcase 3.5.8.1: (implied in previous tests)
---------------------------------------------

Testcase 3.5.8.2: (implied in previous tests)
---------------------------------------------

Testcase 3.5.8.3/4:
-------------------
create database db_test;
grant SELECT, INSERT, UPDATE, DELETE on db_test.* to test_general;
grant LOCK TABLES on db_test.* to test_general;
Use db_test;
unknown's avatar
unknown committed
87
create table t1_i (
88 89 90 91
i120 char ascii not null DEFAULT b'101',
i136 smallint zerofill not null DEFAULT 999,
i144 int zerofill not null DEFAULT 99999,
i163 decimal (63,30)) engine=memory;
unknown's avatar
unknown committed
92
create table t1_u (
93 94 95 96
u120 char ascii not null DEFAULT b'101',
u136 smallint zerofill not null DEFAULT 999,
u144 int zerofill not null DEFAULT 99999,
u163 decimal (63,30)) engine=memory;
unknown's avatar
unknown committed
97
create table t1_d (
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
d120 char ascii not null DEFAULT b'101',
d136 smallint zerofill not null DEFAULT 999,
d144 int zerofill not null DEFAULT 99999,
d163 decimal (63,30)) engine=memory;
Insert into t1_u values ('a',111,99999,999.99);
Insert into t1_u values ('b',222,99999,999.99);
Insert into t1_u values ('c',333,99999,999.99);
Insert into t1_u values ('d',222,99999,999.99);
Insert into t1_u values ('e',222,99999,999.99);
Insert into t1_u values ('f',333,99999,999.99);
Insert into t1_d values ('a',111,99999,999.99);
Insert into t1_d values ('b',222,99999,999.99);
Insert into t1_d values ('c',333,99999,999.99);
Insert into t1_d values ('d',444,99999,999.99);
Insert into t1_d values ('e',222,99999,999.99);
Insert into t1_d values ('f',222,99999,999.99);

3.5.8.4 - multiple SQL
----------------------
use test;
Create trigger trg1 AFTER INSERT on tb3 for each row
BEGIN
unknown's avatar
unknown committed
120
insert into db_test.t1_i
121
values (new.f120, new.f136, new.f144, new.f163);
unknown's avatar
unknown committed
122
update db_test.t1_u
123
set u144=new.f144, u163=new.f163
unknown's avatar
unknown committed
124
where u136=new.f136;
125
delete from db_test.t1_d where d136= new.f136;
unknown's avatar
unknown committed
126 127
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u
where u136= new.f136;
128 129 130
END//
Use test;
set @test_var=0;
unknown's avatar
unknown committed
131
Insert into tb3 (f120, f122, f136, f144, f163)
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
values ('1', 'Test 3.5.8.4', 222, 23456, 1.05);
Select f120, f122, f136, f144, f163 from tb3 where f122= 'Test 3.5.8.4';
f120	f122	f136	f144	f163
1	Test 3.5.8.4	00222	0000023456	1.050000000000000000000000000000
select * from db_test.t1_i;
i120	i136	i144	i163
1	00222	0000023456	1.050000000000000000000000000000
select * from db_test.t1_u;
u120	u136	u144	u163
a	00111	0000099999	999.990000000000000000000000000000
b	00222	0000023456	1.050000000000000000000000000000
c	00333	0000099999	999.990000000000000000000000000000
d	00222	0000023456	1.050000000000000000000000000000
e	00222	0000023456	1.050000000000000000000000000000
f	00333	0000099999	999.990000000000000000000000000000
select * from db_test.t1_d;
d120	d136	d144	d163
a	00111	0000099999	999.990000000000000000000000000000
c	00333	0000099999	999.990000000000000000000000000000
d	00444	0000099999	999.990000000000000000000000000000
select @test_var;
@test_var
3.150000000000000000000000000000

3.5.8.4 - single SQL - insert
-----------------------------
Create trigger trg2 BEFORE UPDATE on tb3 for each row
unknown's avatar
unknown committed
159 160
BEGIN
insert into db_test.t1_i
161
values (new.f120, new.f136, new.f144, new.f163);
unknown's avatar
unknown committed
162 163 164 165 166 167 168
END//
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120	f122	f136	f144	f163
1	Test 3.5.8.4	00222	0000023456	1.050000000000000000000000000000
select * from db_test.t1_i order by i120;
i120	i136	i144	i163
1	00222	0000023456	1.050000000000000000000000000000
169 170 171 172 173
update tb3 set f120='I', f122='Test 3.5.8.4-Single Insert'
		 where f122='Test 3.5.8.4';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120	f122	f136	f144	f163
I	Test 3.5.8.4-Single Insert	00222	0000023456	1.050000000000000000000000000000
unknown's avatar
unknown committed
174
select * from db_test.t1_i order by i120;
175 176 177 178 179 180 181 182
i120	i136	i144	i163
1	00222	0000023456	1.050000000000000000000000000000
I	00222	0000023456	1.050000000000000000000000000000

3.5.8.4 - single SQL - update
-----------------------------
drop trigger trg2;
Create trigger trg3 BEFORE UPDATE on tb3 for each row
unknown's avatar
unknown committed
183
update db_test.t1_u
184 185 186 187 188 189 190
set u120=new.f120
where u136=new.f136;
update tb3 set f120='U', f122='Test 3.5.8.4-Single Update'
		 where f122='Test 3.5.8.4-Single Insert';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120	f122	f136	f144	f163
U	Test 3.5.8.4-Single Update	00222	0000023456	1.050000000000000000000000000000
unknown's avatar
unknown committed
191
select * from db_test.t1_u order by u120;
192 193 194
u120	u136	u144	u163
a	00111	0000099999	999.990000000000000000000000000000
c	00333	0000099999	999.990000000000000000000000000000
unknown's avatar
unknown committed
195 196
f	00333	0000099999	999.990000000000000000000000000000
U	00222	0000023456	1.050000000000000000000000000000
197 198 199 200 201 202 203 204
U	00222	0000023456	1.050000000000000000000000000000
U	00222	0000023456	1.050000000000000000000000000000

3.5.8.3/4 - single SQL - delete
-------------------------------
drop trigger trg3;
Create trigger trg4 AFTER UPDATE on tb3 for each row
delete from db_test.t1_d where d136= new.f136;
unknown's avatar
unknown committed
205
update tb3 set f120='D', f136=444,
206 207 208 209 210
f122='Test 3.5.8.4-Single Delete'
		 where f122='Test 3.5.8.4-Single Update';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120	f122	f136	f144	f163
D	Test 3.5.8.4-Single Delete	00444	0000023456	1.050000000000000000000000000000
unknown's avatar
unknown committed
211
select * from db_test.t1_d order by d120;
212 213 214 215 216 217 218 219
d120	d136	d144	d163
a	00111	0000099999	999.990000000000000000000000000000
c	00333	0000099999	999.990000000000000000000000000000

3.5.8.3/4 - single SQL - select
-------------------------------
drop trigger trg4;
Create trigger trg5 AFTER UPDATE on tb3 for each row
unknown's avatar
unknown committed
220
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u
221 222
where u136= new.f136;
set @test_var=0;
unknown's avatar
unknown committed
223
update tb3 set f120='S', f136=111,
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
f122='Test 3.5.8.4-Single Select'
		 where f122='Test 3.5.8.4-Single Delete';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120	f122	f136	f144	f163
S	Test 3.5.8.4-Single Select	00111	0000023456	1.050000000000000000000000000000
select @test_var;
@test_var
999.990000000000000000000000000000
drop trigger trg1;
drop trigger trg5;
drop database if exists db_test;
delete from tb3 where f122 like 'Test 3.5.8.4%';
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';

Testcase 3.5.8.5 (IF):
----------------------
create trigger trg2 before insert on tb3 for each row
BEGIN
IF new.f120='1' then
set @test_var='one', new.f120='2';
ELSEIF new.f120='2' then
set @test_var='two', new.f120='3';
ELSEIF new.f120='3' then
set @test_var='three', new.f120='4';
END IF;
IF (new.f120='4') and (new.f136=10) then
set @test_var2='2nd if', new.f120='d';
unknown's avatar
unknown committed
251
ELSE
252 253 254 255 256
set @test_var2='2nd else', new.f120='D';
END IF;
END//
set @test_var='Empty', @test_var2=0;
Insert into tb3 (f120, f122, f136) values ('1', 'Test 3.5.8.5-if', 101);
unknown's avatar
unknown committed
257 258
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
259 260 261
f120	f122	f136	@test_var	@test_var2
D	Test 3.5.8.5-if	00101	one	2nd else
Insert into tb3 (f120, f122, f136) values ('2', 'Test 3.5.8.5-if', 102);
unknown's avatar
unknown committed
262 263
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
264 265 266 267
f120	f122	f136	@test_var	@test_var2
D	Test 3.5.8.5-if	00101	two	2nd else
D	Test 3.5.8.5-if	00102	two	2nd else
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 10);
unknown's avatar
unknown committed
268 269
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
270
f120	f122	f136	@test_var	@test_var2
unknown's avatar
unknown committed
271
d	Test 3.5.8.5-if	00010	three	2nd if
272 273 274
D	Test 3.5.8.5-if	00101	three	2nd if
D	Test 3.5.8.5-if	00102	three	2nd if
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 103);
unknown's avatar
unknown committed
275 276
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
277
f120	f122	f136	@test_var	@test_var2
unknown's avatar
unknown committed
278
d	Test 3.5.8.5-if	00010	three	2nd else
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
D	Test 3.5.8.5-if	00101	three	2nd else
D	Test 3.5.8.5-if	00102	three	2nd else
D	Test 3.5.8.5-if	00103	three	2nd else
create trigger trg3 before update on tb3 for each row
BEGIN
ELSEIF new.f120='2' then
END IF;
END//
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
END IF;
END' at line 3
drop trigger trg3//
create trigger trg4 before update on tb3 for each row
BEGIN
IF (new.f120='4') and (new.f136=10) then
set @test_var2='2nd if', new.f120='d';
unknown's avatar
unknown committed
295
ELSE
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
set @test_var2='2nd else', new.f120='D';
END//
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
drop trigger trg4;
drop trigger trg2;
delete from tb3 where f121='Test 3.5.8.5-if';

Testcase 3.5.8.5-case:
----------------------
create trigger trg3 before insert on tb3 for each row
BEGIN
SET new.f120=char(ascii(new.f120)-32);
CASE
when new.f136<100 then set new.f136=new.f136+120;
when new.f136<10 then set new.f144=777;
when new.f136>100 then set new.f120=new.f136-1;
END case;
CASE
when new.f136=200 then set @test_var=CONCAT(new.f120, '=');
ELSE set @test_var=concat(new.f120, '*');
END case;
CASE new.f144
when 1 then set @test_var=concat(@test_var, 'one');
when 2 then set @test_var=concat(@test_var, 'two');
when 3 then set @test_var=concat(@test_var, 'three');
when 4 then set @test_var=concat(@test_var, 'four');
when 5 then set @test_var=concat(@test_var, 'five');
when 6 then set @test_var=concat(@test_var, 'six');
when 7 then set @test_var=concat(@test_var, 'seven');
when 8 then set @test_var=concat(@test_var, 'eight');
when 9 then set @test_var=concat(@test_var, 'nine');
when 10 then set @test_var=concat(@test_var, 'ten');
when 11 then set @test_var=concat(@test_var, 'eleven');
when 12 then set @test_var=concat(@test_var, 'twelve');
when 13 then set @test_var=concat(@test_var, 'thirteen');
when 14 then set @test_var=concat(@test_var, 'fourteen');
when 15 then set @test_var=concat(@test_var, 'fifteen');
ELSE set @test_var=CONCAT(new.f120, '*', new.f144);
END case;
END//
set @test_var='Empty';
unknown's avatar
unknown committed
337
Insert into tb3 (f120, f122, f136, f144)
338
values ('a', 'Test 3.5.8.5-case', 5, 7);
unknown's avatar
unknown committed
339 340
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
341 342
f120	f122	f136	f144	@test_var
A	Test 3.5.8.5-case	00125	0000000007	A*seven
unknown's avatar
unknown committed
343
Insert into tb3 (f120, f122, f136, f144)
344
values ('b', 'Test 3.5.8.5-case', 71,16);
unknown's avatar
unknown committed
345 346
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
347 348 349
f120	f122	f136	f144	@test_var
A	Test 3.5.8.5-case	00125	0000000007	B*0000000016
B	Test 3.5.8.5-case	00191	0000000016	B*0000000016
unknown's avatar
unknown committed
350
Insert into tb3 (f120, f122, f136, f144)
351
values ('c', 'Test 3.5.8.5-case', 80,1);
unknown's avatar
unknown committed
352 353
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
354 355 356 357
f120	f122	f136	f144	@test_var
A	Test 3.5.8.5-case	00125	0000000007	C=one
B	Test 3.5.8.5-case	00191	0000000016	C=one
C	Test 3.5.8.5-case	00200	0000000001	C=one
unknown's avatar
unknown committed
358
Insert into tb3 (f120, f122, f136)
359 360 361
values ('d', 'Test 3.5.8.5-case', 152);
Warnings:
Warning	1265	Data truncated for column 'f120' at row 1
unknown's avatar
unknown committed
362 363
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
364
f120	f122	f136	f144	@test_var
unknown's avatar
unknown committed
365
1	Test 3.5.8.5-case	00152	0000099999	1*0000099999
366 367 368
A	Test 3.5.8.5-case	00125	0000000007	1*0000099999
B	Test 3.5.8.5-case	00191	0000000016	1*0000099999
C	Test 3.5.8.5-case	00200	0000000001	1*0000099999
unknown's avatar
unknown committed
369
Insert into tb3 (f120, f122, f136, f144)
370 371 372
values ('e', 'Test 3.5.8.5-case', 200, 8);
Warnings:
Warning	1265	Data truncated for column 'f120' at row 1
unknown's avatar
unknown committed
373 374
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
375
f120	f122	f136	f144	@test_var
unknown's avatar
unknown committed
376 377
1	Test 3.5.8.5-case	00152	0000099999	1=eight
1	Test 3.5.8.5-case	00200	0000000008	1=eight
378 379 380
A	Test 3.5.8.5-case	00125	0000000007	1=eight
B	Test 3.5.8.5-case	00191	0000000016	1=eight
C	Test 3.5.8.5-case	00200	0000000001	1=eight
unknown's avatar
unknown committed
381
Insert into tb3 (f120, f122, f136, f144)
382
values ('f', 'Test 3.5.8.5-case', 100, 8);
unknown's avatar
unknown committed
383 384
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
385
f120	f122	f136	f144	@test_var
unknown's avatar
unknown committed
386 387
1	Test 3.5.8.5-case	00152	0000099999	1=eight
1	Test 3.5.8.5-case	00200	0000000008	1=eight
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
A	Test 3.5.8.5-case	00125	0000000007	1=eight
B	Test 3.5.8.5-case	00191	0000000016	1=eight
C	Test 3.5.8.5-case	00200	0000000001	1=eight
create trigger trg3a before update on tb3 for each row
BEGIN
CASE
when new.f136<100 then set new.f120='p';
END//
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
drop trigger trg3a;
drop trigger trg3;
delete from tb3 where f121='Test 3.5.8.5-case';

Testcase 3.5.8.5-loop/leave:
----------------------------
Create trigger trg4 after insert on tb3 for each row
unknown's avatar
unknown committed
404
BEGIN
405
set @counter=0, @flag='Initial';
unknown's avatar
unknown committed
406
Label1: loop
407 408
if new.f136<new.f144 then
set @counter='Nothing to loop';
unknown's avatar
unknown committed
409
leave Label1;
410 411 412 413 414
else
set @counter=@counter+1;
if new.f136=new.f144+@counter then
set @counter=concat(@counter, ' loops');
leave Label1;
unknown's avatar
unknown committed
415 416 417
end if;
end if;
iterate label1;
418
set @flag='Final';
unknown's avatar
unknown committed
419
END loop Label1;
420
END//
unknown's avatar
unknown committed
421
Insert into tb3 (f122, f136, f144)
422 423 424 425
values ('Test 3.5.8.5-loop', 2, 8);
select @counter, @flag;
@counter	@flag
Nothing to loop	Initial
unknown's avatar
unknown committed
426
Insert into tb3 (f122, f136, f144)
427 428 429 430 431
values ('Test 3.5.8.5-loop', 11, 8);
select @counter, @flag;
@counter	@flag
3 loops	Initial
Create trigger trg4_2 after update on tb3 for each row
unknown's avatar
unknown committed
432 433
BEGIN
Label1: loop
434
set @counter=@counter+1;
unknown's avatar
unknown committed
435
END;
436
END//
unknown's avatar
unknown committed
437
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 ';
438 439 440 441 442 443 444 445 446
END' at line 5
drop trigger trg4_2;
drop trigger trg4;
delete from tb3 where f122='Test 3.5.8.5-loop';

Testcase 3.5.8.5-repeat:
------------------------
Create trigger trg6 after insert on tb3 for each row
BEGIN
unknown's avatar
unknown committed
447 448
rp_label: REPEAT
SET @counter1 = @counter1 + 1;
449 450
IF (@counter1 MOD 2 = 0) THEN ITERATE rp_label; 	
END IF;
unknown's avatar
unknown committed
451
SET @counter2 = @counter2 + 1;
452 453 454
UNTIL @counter1> new.f136 END REPEAT rp_label;
END//
set @counter1= 0, @counter2= 0;
unknown's avatar
unknown committed
455
Insert into tb3 (f122, f136)
456 457 458 459 460 461
values ('Test 3.5.8.5-repeat', 13);
select @counter1, @counter2;
@counter1	@counter2
15	8
Create trigger trg6_2 after update on tb3 for each row
BEGIN
unknown's avatar
unknown committed
462 463
REPEAT
SET @counter2 = @counter2 + 1;
464 465 466 467 468 469 470 471
END//
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
drop trigger trg6;
delete from tb3 where f122='Test 3.5.8.5-repeat';

Testcase 3.5.8.5-while:
-----------------------
Create trigger trg7 after insert on tb3 for each row
unknown's avatar
unknown committed
472 473
wl_label: WHILE @counter1 < new.f136 DO
SET @counter1 = @counter1 + 1;
474 475
IF (@counter1 MOD 2 = 0) THEN ITERATE wl_label; 	
END IF;
unknown's avatar
unknown committed
476
SET @counter2 = @counter2 + 1;
477 478
END WHILE wl_label//
set @counter1= 0, @counter2= 0;
unknown's avatar
unknown committed
479
Insert into tb3 (f122, f136)
480 481 482 483 484 485
values ('Test 3.5.8.5-while', 7);
select @counter1, @counter2;
@counter1	@counter2
7	4
Create trigger trg7_2 after update on tb3 for each row
BEGIN
unknown's avatar
unknown committed
486 487
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
488
END//
unknown's avatar
unknown committed
489
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;
490
END' at line 4
491 492 493 494 495
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;

Testcase 3.5.8.6: (requirement void)
------------------------------------
unknown's avatar
unknown committed
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
CREATE PROCEDURE sp_01 () BEGIN set @v1=1; END//
CREATE TRIGGER trg8_1 BEFORE UPDATE ON tb3 FOR EACH ROW
BEGIN
CALL sp_01 ();
END//
Insert into tb3 (f120, f122, f136) values ('6', 'Test 3.5.8.6-insert', 101);
update tb3 set f120='S', f136=111,
f122='Test 3.5.8.6-tr8_1'
	       where f122='Test 3.5.8.6-insert';
select f120, f122
from tb3 where f122  like 'Test 3.5.8.6%' order by f120;
f120	f122
S	Test 3.5.8.6-tr8_1
DROP TRIGGER trg8_1;
DROP PROCEDURE sp_01;
511

unknown's avatar
unknown committed
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527
Testcase 3.5.8.7
----------------
Create trigger trg9_1 before update on tb3 for each row
BEGIN
Start transaction;
Set new.f120='U';
Commit;
END//
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
Create trigger trg9_2 before delete on tb3 for each row
BEGIN
Start transaction;
Set @var2=old.f120;
Rollback;
END//
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
528 529 530
drop user test_general@localhost;
drop user test_general;
drop user test_super@localhost;
531
DROP TABLE test.tb3;