~jlukas79/+junk/mysql-server

« back to all changes in this revision

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

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
1
2
USE test;
2
3
drop table if exists tb3;
3
4
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 char(50), 
8
 
f122 char(50), 
9
 
f129 binary not null DEFAULT b'101', 
10
 
f130 tinyint not null DEFAULT 99, 
11
 
f131 tinyint unsigned not null DEFAULT 99, 
12
 
f132 tinyint zerofill not null DEFAULT 99, 
13
 
f133 tinyint unsigned zerofill not null DEFAULT 99, 
14
 
f134 smallint not null DEFAULT 999, 
15
 
f135 smallint unsigned not null DEFAULT 999, 
16
 
f136 smallint zerofill not null DEFAULT 999,  
17
 
f137 smallint unsigned zerofill not null DEFAULT 999, 
18
 
f138 mediumint not null DEFAULT 9999, 
19
 
f139 mediumint unsigned not null DEFAULT 9999, 
20
 
f140 mediumint zerofill not null DEFAULT 9999, 
21
 
f141 mediumint unsigned zerofill not null DEFAULT 9999, 
22
 
f142 int not null DEFAULT 99999, 
23
 
f143 int unsigned not null DEFAULT 99999, 
24
 
f144 int zerofill not null DEFAULT 99999, 
25
 
f145 int unsigned zerofill not null DEFAULT 99999, 
26
 
f146 bigint not null DEFAULT 999999, 
27
 
f147 bigint unsigned not null DEFAULT 999999, 
28
 
f148 bigint zerofill not null DEFAULT 999999, 
29
 
f149 bigint unsigned zerofill not null DEFAULT 999999, 
30
 
f150 decimal not null DEFAULT 999.999, 
31
 
f151 decimal unsigned not null DEFAULT 999.17, 
32
 
f152 decimal zerofill not null DEFAULT 999.999, 
33
 
f153 decimal unsigned zerofill, 
34
 
f154 decimal (0), 
35
 
f155 decimal (64), 
36
 
f156 decimal (0) unsigned, 
37
 
f157 decimal (64) unsigned, 
38
 
f158 decimal (0) zerofill, 
39
 
f159 decimal (64) zerofill, 
40
 
f160 decimal (0) unsigned zerofill, 
41
 
f161 decimal (64) unsigned zerofill, 
42
 
f162 decimal (0,0), 
43
 
f163 decimal (63,30), 
44
 
f164 decimal (0,0) unsigned, 
45
 
f165 decimal (63,30) unsigned, 
46
 
f166 decimal (0,0) zerofill, 
47
 
f167 decimal (63,30) zerofill, 
48
 
f168 decimal (0,0) unsigned zerofill, 
49
 
f169 decimal (63,30) unsigned zerofill, 
50
 
f170 numeric, 
51
 
f171 numeric unsigned, 
52
 
f172 numeric zerofill, 
53
 
f173 numeric unsigned zerofill, 
54
 
f174 numeric (0), 
55
 
f175 numeric (64) 
56
 
) engine = memory;
 
5
f118 char not null DEFAULT 'a',
 
6
f119 char binary not null DEFAULT b'101',
 
7
f120 char ascii not null DEFAULT b'101',
 
8
f121 char(50),
 
9
f122 char(50),
 
10
f129 binary not null DEFAULT b'101',
 
11
f130 tinyint not null DEFAULT 99,
 
12
f131 tinyint unsigned not null DEFAULT 99,
 
13
f132 tinyint zerofill not null DEFAULT 99,
 
14
f133 tinyint unsigned zerofill not null DEFAULT 99,
 
15
f134 smallint not null DEFAULT 999,
 
16
f135 smallint unsigned not null DEFAULT 999,
 
17
f136 smallint zerofill not null DEFAULT 999,
 
18
f137 smallint unsigned zerofill not null DEFAULT 999,
 
19
f138 mediumint not null DEFAULT 9999,
 
20
f139 mediumint unsigned not null DEFAULT 9999,
 
21
f140 mediumint zerofill not null DEFAULT 9999,
 
22
f141 mediumint unsigned zerofill not null DEFAULT 9999,
 
23
f142 int not null DEFAULT 99999,
 
24
f143 int unsigned not null DEFAULT 99999,
 
25
f144 int zerofill not null DEFAULT 99999,
 
26
f145 int unsigned zerofill not null DEFAULT 99999,
 
27
f146 bigint not null DEFAULT 999999,
 
28
f147 bigint unsigned not null DEFAULT 999999,
 
29
f148 bigint zerofill not null DEFAULT 999999,
 
30
f149 bigint unsigned zerofill not null DEFAULT 999999,
 
31
f150 decimal not null DEFAULT 999.999,
 
32
f151 decimal unsigned not null DEFAULT 999.17,
 
33
f152 decimal zerofill not null DEFAULT 999.999,
 
34
f153 decimal unsigned zerofill,
 
35
f154 decimal (0),
 
36
f155 decimal (64),
 
37
f156 decimal (0) unsigned,
 
38
f157 decimal (64) unsigned,
 
39
f158 decimal (0) zerofill,
 
40
f159 decimal (64) zerofill,
 
41
f160 decimal (0) unsigned zerofill,
 
42
f161 decimal (64) unsigned zerofill,
 
43
f162 decimal (0,0),
 
44
f163 decimal (63,30),
 
45
f164 decimal (0,0) unsigned,
 
46
f165 decimal (63,30) unsigned,
 
47
f166 decimal (0,0) zerofill,
 
48
f167 decimal (63,30) zerofill,
 
49
f168 decimal (0,0) unsigned zerofill,
 
50
f169 decimal (63,30) unsigned zerofill,
 
51
f170 numeric,
 
52
f171 numeric unsigned,
 
53
f172 numeric zerofill,
 
54
f173 numeric unsigned zerofill,
 
55
f174 numeric (0),
 
56
f175 numeric (64)
 
57
) engine = <engine_to_be_used>;
57
58
Warnings:
58
59
Note    1265    Data truncated for column 'f150' at row 1
59
60
Note    1265    Data truncated for column 'f151' at row 1
60
61
Note    1265    Data truncated for column 'f152' at row 1
61
 
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/memory_tb3.txt' into table tb3 ;
62
62
 
63
63
Testcase: 3.5:
64
64
--------------
83
83
grant SELECT, INSERT, UPDATE, DELETE on db_test.* to test_general;
84
84
grant LOCK TABLES on db_test.* to test_general;
85
85
Use db_test;
86
 
create table t1_i ( 
 
86
create table t1_i (
87
87
i120 char ascii not null DEFAULT b'101',
88
88
i136 smallint zerofill not null DEFAULT 999,
89
89
i144 int zerofill not null DEFAULT 99999,
90
 
i163 decimal (63,30)) engine=memory;
91
 
create table t1_u ( 
 
90
i163 decimal (63,30)) engine=<engine_to_be_used>;
 
91
create table t1_u (
92
92
u120 char ascii not null DEFAULT b'101',
93
93
u136 smallint zerofill not null DEFAULT 999,
94
94
u144 int zerofill not null DEFAULT 99999,
95
 
u163 decimal (63,30)) engine=memory;
96
 
create table t1_d ( 
 
95
u163 decimal (63,30)) engine=<engine_to_be_used>;
 
96
create table t1_d (
97
97
d120 char ascii not null DEFAULT b'101',
98
98
d136 smallint zerofill not null DEFAULT 999,
99
99
d144 int zerofill not null DEFAULT 99999,
100
 
d163 decimal (63,30)) engine=memory;
 
100
d163 decimal (63,30)) engine=<engine_to_be_used>;
101
101
Insert into t1_u values ('a',111,99999,999.99);
102
102
Insert into t1_u values ('b',222,99999,999.99);
103
103
Insert into t1_u values ('c',333,99999,999.99);
116
116
use test;
117
117
Create trigger trg1 AFTER INSERT on tb3 for each row
118
118
BEGIN
119
 
insert into db_test.t1_i 
 
119
insert into db_test.t1_i
120
120
values (new.f120, new.f136, new.f144, new.f163);
121
 
update db_test.t1_u 
 
121
update db_test.t1_u
122
122
set u144=new.f144, u163=new.f163
123
 
where u136=new.f136; 
 
123
where u136=new.f136;
124
124
delete from db_test.t1_d where d136= new.f136;
125
 
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u 
126
 
where u136= new.f136; 
 
125
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u
 
126
where u136= new.f136;
127
127
END//
128
128
Use test;
129
129
set @test_var=0;
130
 
Insert into tb3 (f120, f122, f136, f144, f163) 
 
130
Insert into tb3 (f120, f122, f136, f144, f163)
131
131
values ('1', 'Test 3.5.8.4', 222, 23456, 1.05);
132
132
Select f120, f122, f136, f144, f163 from tb3 where f122= 'Test 3.5.8.4';
133
133
f120    f122    f136    f144    f163
156
156
-----------------------------
157
157
Create trigger trg2 BEFORE UPDATE on tb3 for each row
158
158
BEGIN
159
 
insert into db_test.t1_i 
 
159
insert into db_test.t1_i
160
160
values (new.f120, new.f136, new.f144, new.f163);
161
161
END//
162
162
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
179
179
-----------------------------
180
180
drop trigger trg2;
181
181
Create trigger trg3 BEFORE UPDATE on tb3 for each row
182
 
update db_test.t1_u 
 
182
update db_test.t1_u
183
183
set u120=new.f120
184
184
where u136=new.f136;
185
185
update tb3 set f120='U', f122='Test 3.5.8.4-Single Update'
201
201
drop trigger trg3;
202
202
Create trigger trg4 AFTER UPDATE on tb3 for each row
203
203
delete from db_test.t1_d where d136= new.f136;
204
 
update tb3 set f120='D', f136=444, 
 
204
update tb3 set f120='D', f136=444,
205
205
f122='Test 3.5.8.4-Single Delete'
206
206
                 where f122='Test 3.5.8.4-Single Update';
207
207
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
216
216
-------------------------------
217
217
drop trigger trg4;
218
218
Create trigger trg5 AFTER UPDATE on tb3 for each row
219
 
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u 
 
219
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u
220
220
where u136= new.f136;
221
221
set @test_var=0;
222
 
update tb3 set f120='S', f136=111, 
 
222
update tb3 set f120='S', f136=111,
223
223
f122='Test 3.5.8.4-Single Select'
224
224
                 where f122='Test 3.5.8.4-Single Delete';
225
225
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
247
247
END IF;
248
248
IF (new.f120='4') and (new.f136=10) then
249
249
set @test_var2='2nd if', new.f120='d';
250
 
ELSE 
 
250
ELSE
251
251
set @test_var2='2nd else', new.f120='D';
252
252
END IF;
253
253
END//
254
254
set @test_var='Empty', @test_var2=0;
255
255
Insert into tb3 (f120, f122, f136) values ('1', 'Test 3.5.8.5-if', 101);
256
 
select f120, f122, f136, @test_var, @test_var2 
 
256
select f120, f122, f136, @test_var, @test_var2
257
257
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
258
258
f120    f122    f136    @test_var       @test_var2
259
259
D       Test 3.5.8.5-if 00101   one     2nd else
260
260
Insert into tb3 (f120, f122, f136) values ('2', 'Test 3.5.8.5-if', 102);
261
 
select f120, f122, f136, @test_var, @test_var2 
 
261
select f120, f122, f136, @test_var, @test_var2
262
262
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
263
263
f120    f122    f136    @test_var       @test_var2
264
264
D       Test 3.5.8.5-if 00101   two     2nd else
265
265
D       Test 3.5.8.5-if 00102   two     2nd else
266
266
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 10);
267
 
select f120, f122, f136, @test_var, @test_var2 
 
267
select f120, f122, f136, @test_var, @test_var2
268
268
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
269
269
f120    f122    f136    @test_var       @test_var2
270
270
d       Test 3.5.8.5-if 00010   three   2nd if
271
271
D       Test 3.5.8.5-if 00101   three   2nd if
272
272
D       Test 3.5.8.5-if 00102   three   2nd if
273
273
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 103);
274
 
select f120, f122, f136, @test_var, @test_var2 
 
274
select f120, f122, f136, @test_var, @test_var2
275
275
from tb3 where f122 = 'Test 3.5.8.5-if' order by f136;
276
276
f120    f122    f136    @test_var       @test_var2
277
277
d       Test 3.5.8.5-if 00010   three   2nd else
291
291
BEGIN
292
292
IF (new.f120='4') and (new.f136=10) then
293
293
set @test_var2='2nd if', new.f120='d';
294
 
ELSE 
 
294
ELSE
295
295
set @test_var2='2nd else', new.f120='D';
296
296
END//
297
297
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
333
333
END case;
334
334
END//
335
335
set @test_var='Empty';
336
 
Insert into tb3 (f120, f122, f136, f144) 
 
336
Insert into tb3 (f120, f122, f136, f144)
337
337
values ('a', 'Test 3.5.8.5-case', 5, 7);
338
 
select f120, f122, f136, f144, @test_var 
 
338
select f120, f122, f136, f144, @test_var
339
339
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
340
340
f120    f122    f136    f144    @test_var
341
341
A       Test 3.5.8.5-case       00125   0000000007      A*seven
342
 
Insert into tb3 (f120, f122, f136, f144) 
 
342
Insert into tb3 (f120, f122, f136, f144)
343
343
values ('b', 'Test 3.5.8.5-case', 71,16);
344
 
select f120, f122, f136, f144, @test_var 
 
344
select f120, f122, f136, f144, @test_var
345
345
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
346
346
f120    f122    f136    f144    @test_var
347
347
A       Test 3.5.8.5-case       00125   0000000007      B*0000000016
348
348
B       Test 3.5.8.5-case       00191   0000000016      B*0000000016
349
 
Insert into tb3 (f120, f122, f136, f144) 
 
349
Insert into tb3 (f120, f122, f136, f144)
350
350
values ('c', 'Test 3.5.8.5-case', 80,1);
351
 
select f120, f122, f136, f144, @test_var 
 
351
select f120, f122, f136, f144, @test_var
352
352
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
353
353
f120    f122    f136    f144    @test_var
354
354
A       Test 3.5.8.5-case       00125   0000000007      C=one
355
355
B       Test 3.5.8.5-case       00191   0000000016      C=one
356
356
C       Test 3.5.8.5-case       00200   0000000001      C=one
357
 
Insert into tb3 (f120, f122, f136) 
 
357
Insert into tb3 (f120, f122, f136)
358
358
values ('d', 'Test 3.5.8.5-case', 152);
359
359
Warnings:
360
360
Warning 1265    Data truncated for column 'f120' at row 1
361
 
select f120, f122, f136, f144, @test_var 
 
361
select f120, f122, f136, f144, @test_var
362
362
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
363
363
f120    f122    f136    f144    @test_var
364
364
1       Test 3.5.8.5-case       00152   0000099999      1*0000099999
365
365
A       Test 3.5.8.5-case       00125   0000000007      1*0000099999
366
366
B       Test 3.5.8.5-case       00191   0000000016      1*0000099999
367
367
C       Test 3.5.8.5-case       00200   0000000001      1*0000099999
368
 
Insert into tb3 (f120, f122, f136, f144) 
 
368
Insert into tb3 (f120, f122, f136, f144)
369
369
values ('e', 'Test 3.5.8.5-case', 200, 8);
370
370
Warnings:
371
371
Warning 1265    Data truncated for column 'f120' at row 1
372
 
select f120, f122, f136, f144, @test_var 
 
372
select f120, f122, f136, f144, @test_var
373
373
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
374
374
f120    f122    f136    f144    @test_var
375
375
1       Test 3.5.8.5-case       00152   0000099999      1=eight
377
377
A       Test 3.5.8.5-case       00125   0000000007      1=eight
378
378
B       Test 3.5.8.5-case       00191   0000000016      1=eight
379
379
C       Test 3.5.8.5-case       00200   0000000001      1=eight
380
 
Insert into tb3 (f120, f122, f136, f144) 
 
380
Insert into tb3 (f120, f122, f136, f144)
381
381
values ('f', 'Test 3.5.8.5-case', 100, 8);
382
 
select f120, f122, f136, f144, @test_var 
 
382
select f120, f122, f136, f144, @test_var
383
383
from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
384
384
f120    f122    f136    f144    @test_var
385
385
1       Test 3.5.8.5-case       00152   0000099999      1=eight
400
400
Testcase 3.5.8.5-loop/leave:
401
401
----------------------------
402
402
Create trigger trg4 after insert on tb3 for each row
403
 
BEGIN 
 
403
BEGIN
404
404
set @counter=0, @flag='Initial';
405
 
Label1: loop 
 
405
Label1: loop
406
406
if new.f136<new.f144 then
407
407
set @counter='Nothing to loop';
408
 
leave Label1; 
 
408
leave Label1;
409
409
else
410
410
set @counter=@counter+1;
411
411
if new.f136=new.f144+@counter then
412
412
set @counter=concat(@counter, ' loops');
413
413
leave Label1;
414
 
end if; 
415
 
end if; 
416
 
iterate label1; 
 
414
end if;
 
415
end if;
 
416
iterate label1;
417
417
set @flag='Final';
418
 
END loop Label1; 
 
418
END loop Label1;
419
419
END//
420
 
Insert into tb3 (f122, f136, f144) 
 
420
Insert into tb3 (f122, f136, f144)
421
421
values ('Test 3.5.8.5-loop', 2, 8);
422
422
select @counter, @flag;
423
423
@counter        @flag
424
424
Nothing to loop Initial
425
 
Insert into tb3 (f122, f136, f144) 
 
425
Insert into tb3 (f122, f136, f144)
426
426
values ('Test 3.5.8.5-loop', 11, 8);
427
427
select @counter, @flag;
428
428
@counter        @flag
429
429
3 loops Initial
430
430
Create trigger trg4_2 after update on tb3 for each row
431
 
BEGIN 
432
 
Label1: loop 
 
431
BEGIN
 
432
Label1: loop
433
433
set @counter=@counter+1;
434
 
END;  
 
434
END;
435
435
END//
436
 
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 ';  
 
436
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 ';
437
437
END' at line 5
438
438
drop trigger trg4_2;
439
439
drop trigger trg4;
443
443
------------------------
444
444
Create trigger trg6 after insert on tb3 for each row
445
445
BEGIN
446
 
rp_label: REPEAT 
447
 
SET @counter1 = @counter1 + 1; 
 
446
rp_label: REPEAT
 
447
SET @counter1 = @counter1 + 1;
448
448
IF (@counter1 MOD 2 = 0) THEN ITERATE rp_label;         
449
449
END IF;
450
 
SET @counter2 = @counter2 + 1; 
 
450
SET @counter2 = @counter2 + 1;
451
451
UNTIL @counter1> new.f136 END REPEAT rp_label;
452
452
END//
453
453
set @counter1= 0, @counter2= 0;
454
 
Insert into tb3 (f122, f136) 
 
454
Insert into tb3 (f122, f136)
455
455
values ('Test 3.5.8.5-repeat', 13);
456
456
select @counter1, @counter2;
457
457
@counter1       @counter2
458
458
15      8
459
459
Create trigger trg6_2 after update on tb3 for each row
460
460
BEGIN
461
 
REPEAT 
462
 
SET @counter2 = @counter2 + 1; 
 
461
REPEAT
 
462
SET @counter2 = @counter2 + 1;
463
463
END//
464
464
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
465
465
drop trigger trg6;
468
468
Testcase 3.5.8.5-while:
469
469
-----------------------
470
470
Create trigger trg7 after insert on tb3 for each row
471
 
wl_label: WHILE @counter1 < new.f136 DO 
472
 
SET @counter1 = @counter1 + 1; 
 
471
wl_label: WHILE @counter1 < new.f136 DO
 
472
SET @counter1 = @counter1 + 1;
473
473
IF (@counter1 MOD 2 = 0) THEN ITERATE wl_label;         
474
474
END IF;
475
 
SET @counter2 = @counter2 + 1; 
 
475
SET @counter2 = @counter2 + 1;
476
476
END WHILE wl_label//
477
477
set @counter1= 0, @counter2= 0;
478
 
Insert into tb3 (f122, f136) 
 
478
Insert into tb3 (f122, f136)
479
479
values ('Test 3.5.8.5-while', 7);
480
480
select @counter1, @counter2;
481
481
@counter1       @counter2
482
482
7       4
483
483
Create trigger trg7_2 after update on tb3 for each row
484
484
BEGIN
485
 
WHILE @counter1 < new.f136 
486
 
SET @counter1 = @counter1 + 1; 
 
485
WHILE @counter1 < new.f136
 
486
SET @counter1 = @counter1 + 1;
487
487
END//
488
 
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; 
 
488
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;
489
489
END' at line 4
490
490
delete from tb3 where f122='Test 3.5.8.5-while';
491
491
drop trigger trg7;