~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

Viewing changes to mysql-test/suite/funcs_1/r/memory_storedproc_03.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
 
 
2
--source suite/funcs_1/storedproc/load_sp_tb.inc
 
3
--------------------------------------------------------------------------------
 
4
 
 
5
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc
 
6
--------------------------------------------------------------------------------
 
7
DROP DATABASE IF EXISTS db_storedproc;
 
8
DROP DATABASE IF EXISTS db_storedproc_1;
 
9
CREATE DATABASE db_storedproc;
 
10
CREATE DATABASE db_storedproc_1;
 
11
USE db_storedproc;
 
12
create table t1(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = memory;
 
13
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t1;
 
14
create table t2(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = memory;
 
15
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t2;
 
16
create table t3(f1 char(20),f2 char(20),f3 integer) engine = memory;
 
17
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t3.txt' into table t3;
 
18
create table t4(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = memory;
 
19
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t4;
 
20
USE db_storedproc_1;
 
21
create table t6(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = memory;
 
22
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t6;
 
23
USE db_storedproc;
 
24
create table t7 (f1 char(20), f2 char(25), f3 date, f4 int) engine = memory;
 
25
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t7.txt' into table t7;
 
26
Warnings:
 
27
Warning 1265    Data truncated for column 'f3' at row 1
 
28
Warning 1265    Data truncated for column 'f3' at row 2
 
29
Warning 1265    Data truncated for column 'f3' at row 3
 
30
Warning 1265    Data truncated for column 'f3' at row 4
 
31
Warning 1265    Data truncated for column 'f3' at row 5
 
32
Warning 1265    Data truncated for column 'f3' at row 6
 
33
Warning 1265    Data truncated for column 'f3' at row 7
 
34
Warning 1265    Data truncated for column 'f3' at row 8
 
35
Warning 1265    Data truncated for column 'f3' at row 9
 
36
Warning 1265    Data truncated for column 'f3' at row 10
 
37
create table t8 (f1 char(20), f2 char(25), f3 date, f4 int) engine = memory;
 
38
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t7.txt' into table t8;
 
39
Warnings:
 
40
Warning 1265    Data truncated for column 'f3' at row 1
 
41
Warning 1265    Data truncated for column 'f3' at row 2
 
42
Warning 1265    Data truncated for column 'f3' at row 3
 
43
Warning 1265    Data truncated for column 'f3' at row 4
 
44
Warning 1265    Data truncated for column 'f3' at row 5
 
45
Warning 1265    Data truncated for column 'f3' at row 6
 
46
Warning 1265    Data truncated for column 'f3' at row 7
 
47
Warning 1265    Data truncated for column 'f3' at row 8
 
48
Warning 1265    Data truncated for column 'f3' at row 9
 
49
Warning 1265    Data truncated for column 'f3' at row 10
 
50
create table t9(f1 int, f2 char(25), f3 int) engine = memory;
 
51
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t9.txt' into table t9;
 
52
create table t10(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = memory;
 
53
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t10;
 
54
create table t11(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = memory;
 
55
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t11;
 
56
 
 
57
Section 3.1.3 - Syntax checks for the stored procedure-specific flow
 
58
control statements IF, CASE, LOOP, LEAVE, ITERATE, REPEAT, WHILE:
 
59
--------------------------------------------------------------------------------
 
60
 
 
61
Testcase 3.1.3.7:
 
62
-----------------
 
63
 
 
64
Ensure that the IF statement acts correctly for all variants, including cases
 
65
where statements are nested.
 
66
--------------------------------------------------------------------------------
 
67
DROP TABLE IF EXISTS res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
68
DROP PROCEDURE IF EXISTS sp9;
 
69
CREATE TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742( f1 CHAR(20), f2 VARCHAR(20), f3 SMALLINT);
 
70
CREATE PROCEDURE sp9( action char(20), subaction char(20) )
 
71
BEGIN
 
72
if action = 'action' then
 
73
if subaction = 'subaction' then
 
74
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'action', 'subaction' , 1);
 
75
else
 
76
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'action', 'none' , 2);
 
77
END if;
 
78
else
 
79
if subaction = 'subaction'
 
80
      then
 
81
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'none', 'subaction' , 3);
 
82
elseif subaction = 'subaction1'
 
83
      then
 
84
BEGIN
 
85
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values ('none', 'subaction1', 4);
 
86
END;
 
87
else
 
88
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'none', 'none' , 5);
 
89
END if;
 
90
END if;
 
91
END//
 
92
CALL sp9( 'action', 'subaction' );
 
93
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742 where f3=1;
 
94
f1      f2      f3
 
95
action  subaction       1
 
96
CALL sp9( 'temp', 'subaction' );
 
97
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742 where f3=3;
 
98
f1      f2      f3
 
99
none    subaction       3
 
100
CALL sp9( 'temp', 'subaction1' );
 
101
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742 where f3=4;
 
102
f1      f2      f3
 
103
none    subaction1      4
 
104
CALL sp9( 'action', 'temp' );
 
105
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742 where f3=2;
 
106
f1      f2      f3
 
107
action  none    2
 
108
CALL sp9( 'temp', 'temp' );
 
109
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742 where f3=5;
 
110
f1      f2      f3
 
111
none    none    5
 
112
DROP PROCEDURE sp9;
 
113
DROP TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
114
 
 
115
Testcase 3.1.3.8.:
 
116
------------------
 
117
 
 
118
Ensure that the CASE statement acts correctly for all variants, including cases
 
119
where statements are nested.
 
120
--------------------------------------------------------------------------------
 
121
drop table IF EXISTS res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
122
DROP PROCEDURE IF EXISTS sp10;
 
123
create table res_t3_itisalongname_1381742_itsaverylongname_1381742( f1 char(20), f2 varchar(20), f3 smallint);
 
124
CREATE PROCEDURE sp10( action char(20), subaction char(20) )
 
125
BEGIN
 
126
case action
 
127
when 'action' then
 
128
case
 
129
when subaction = 'subaction_1' then
 
130
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'action', 'subaction_2' , 1);
 
131
when subaction = 'subaction_2' then
 
132
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'action', 'subaction_2' , 2);
 
133
else
 
134
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'action', 'none' , 3);
 
135
END case;
 
136
else
 
137
case
 
138
when subaction = 'subaction_1' then
 
139
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'none', 'subaction_1' , 4);
 
140
when subaction = 'subaction_2' then
 
141
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'none', 'subaction_2' , 5);
 
142
else
 
143
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'none', 'none' , 6);
 
144
END case;
 
145
END case;
 
146
END//
 
147
CALL sp10( 'action', 'subaction_1' );
 
148
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
149
f1      f2      f3
 
150
action  subaction_2     1
 
151
delete from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
152
CALL sp10( 'action', 'subaction_2' );
 
153
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
154
f1      f2      f3
 
155
action  subaction_2     2
 
156
delete from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
157
CALL sp10( 'temp', 'subaction_1' );
 
158
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
159
f1      f2      f3
 
160
none    subaction_1     4
 
161
delete from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
162
CALL sp10( 'temp', 'subaction_2' );
 
163
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
164
f1      f2      f3
 
165
none    subaction_2     5
 
166
delete from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
167
CALL sp10( 'action', 'temp' );
 
168
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
169
f1      f2      f3
 
170
action  none    3
 
171
delete from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
172
CALL sp10( 'temp', 'temp' );
 
173
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
174
f1      f2      f3
 
175
none    none    6
 
176
DROP PROCEDURE sp10;
 
177
DROP TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
178
 
 
179
Testcase 3.1.3.9 + 3.1.3.15:
 
180
----------------------------
 
181
 
 
182
09. Ensure that the LOOP statement acts correctly for all variants, including
 
183
.   cases where statements are nested.
 
184
15. Ensure that the LEAVE statement acts correctly for all variants, including
 
185
.   cases where statements are nested.
 
186
--------------------------------------------------------------------------------
 
187
DROP TABLE IF EXISTS res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
188
DROP PROCEDURE IF EXISTS sp11;
 
189
CREATE TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742( f1 CHAR(20), f2 VARCHAR(20), f3 SMALLINT);
 
190
CREATE PROCEDURE sp11( )
 
191
BEGIN
 
192
declare count1 integer default 1;
 
193
declare count2 integer default 1;
 
194
label1: loop
 
195
if count2 > 3 then leave label1;
 
196
END if;
 
197
set count1 = 1;
 
198
label2: loop
 
199
if count1 > 4 then leave label2;
 
200
END if;
 
201
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'xyz' , 'pqr', count1);
 
202
set count1 = count1 + 1;
 
203
iterate label2;
 
204
END loop label2;
 
205
set count2 = count2 + 1;
 
206
iterate label1;
 
207
END loop label1;
 
208
END//
 
209
CALL sp11();
 
210
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
211
f1      f2      f3
 
212
xyz     pqr     1
 
213
xyz     pqr     2
 
214
xyz     pqr     3
 
215
xyz     pqr     4
 
216
xyz     pqr     1
 
217
xyz     pqr     2
 
218
xyz     pqr     3
 
219
xyz     pqr     4
 
220
xyz     pqr     1
 
221
xyz     pqr     2
 
222
xyz     pqr     3
 
223
xyz     pqr     4
 
224
DROP PROCEDURE sp11;
 
225
DROP TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
226
 
 
227
Testcase 3.1.3.16:
 
228
------------------
 
229
 
 
230
Ensure that the ITERATE statement acts correctly for all variants, including
 
231
cases where statements are nested.
 
232
(tests for this testcase are also included in other testcases)
 
233
--------------------------------------------------------------------------------
 
234
DROP PROCEDURE IF EXISTS sp31316;
 
235
CREATE PROCEDURE sp31316( )
 
236
BEGIN
 
237
declare count1 integer default 1;
 
238
declare count2 integer default 1;
 
239
label1: loop
 
240
if count2 > 3 then leave label1;
 
241
END if;
 
242
set count1 = 1;
 
243
label2: loop
 
244
if count1 > 4 then leave label2;
 
245
END if;
 
246
insert into temp values( count1, count2);
 
247
set count1 = count1 + 1;
 
248
iterate label3;
 
249
END loop label2;
 
250
set count2 = count2 + 1;
 
251
iterate label1;
 
252
END loop label1;
 
253
END//
 
254
ERROR 42000: ITERATE with no matching label: label3
 
255
 
 
256
Testcase 3.1.3.18:
 
257
------------------
 
258
 
 
259
Ensure that the REPEAT statement acts correctly for all variants, including
 
260
cases where statements are nested.
 
261
--------------------------------------------------------------------------------
 
262
DROP PROCEDURE IF EXISTS sp17;
 
263
DROP TABLE IF EXISTS res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
264
CREATE TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742( f1 CHAR(20), f2 VARCHAR(20), f3 SMALLINT);
 
265
CREATE PROCEDURE sp17( )
 
266
BEGIN
 
267
declare count1 integer default 1;
 
268
declare count2 integer default 1;
 
269
repeat
 
270
set count1 = count1 + 1;
 
271
set count2 = 1;
 
272
label1: repeat
 
273
set count2 = count2 + 1;
 
274
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'xyz' , 'pqr', count1);
 
275
until count2 > 3
 
276
END repeat label1;
 
277
until count1 > 3
 
278
END repeat;
 
279
END//
 
280
CALL sp17();
 
281
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
282
f1      f2      f3
 
283
xyz     pqr     2
 
284
xyz     pqr     2
 
285
xyz     pqr     2
 
286
xyz     pqr     3
 
287
xyz     pqr     3
 
288
xyz     pqr     3
 
289
xyz     pqr     4
 
290
xyz     pqr     4
 
291
xyz     pqr     4
 
292
DROP PROCEDURE sp17;
 
293
DROP TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742;
 
294
 
 
295
Testcase 3.1.3.24:
 
296
------------------
 
297
 
 
298
Ensure that the WHILE statement acts correctly for all variants, including cases
 
299
where statements are nested.
 
300
--------------------------------------------------------------------------------
 
301
drop table IF EXISTS res_t21;
 
302
DROP PROCEDURE IF EXISTS sp21;
 
303
create table res_t21(name text(10), surname blob(20), age_averylongfieldname_averylongname_1234569 smallint);
 
304
insert into res_t21 values('ashwin', 'mokadam', 25);
 
305
CREATE PROCEDURE sp21( )
 
306
BEGIN
 
307
declare count1 integer default 0;
 
308
declare count2 integer default 0;
 
309
while count1 < 3 do
 
310
BEGIN
 
311
declare ithisissamevariablename int default 100;
 
312
SELECT ithisissamevariablename;
 
313
BEGIN
 
314
declare ithisissamevariablename int default 200;
 
315
SELECT ithisissamevariablename;
 
316
END;
 
317
set count2 = 0;
 
318
label1: while count2 < 3 do
 
319
BEGIN
 
320
declare count1 integer default 7;
 
321
set count2 = count2 + 1;
 
322
insert into res_t21 values( 'xyz' , 'pqr', count2);
 
323
label2: while count1 < 10 do
 
324
set count1 = count1 + 1;
 
325
insert into res_t21 values( 'xyz' , 'pqr', count1);
 
326
END while label2;
 
327
END;
 
328
END while label1;
 
329
set count1 = count1 + 1;
 
330
END;
 
331
END while;
 
332
END//
 
333
CALL sp21();
 
334
ithisissamevariablename
 
335
100
 
336
ithisissamevariablename
 
337
200
 
338
ithisissamevariablename
 
339
100
 
340
ithisissamevariablename
 
341
200
 
342
ithisissamevariablename
 
343
100
 
344
ithisissamevariablename
 
345
200
 
346
SELECT * from res_t21;
 
347
name    surname age_averylongfieldname_averylongname_1234569
 
348
ashwin  mokadam 25
 
349
xyz     pqr     1
 
350
xyz     pqr     8
 
351
xyz     pqr     9
 
352
xyz     pqr     10
 
353
xyz     pqr     2
 
354
xyz     pqr     8
 
355
xyz     pqr     9
 
356
xyz     pqr     10
 
357
xyz     pqr     3
 
358
xyz     pqr     8
 
359
xyz     pqr     9
 
360
xyz     pqr     10
 
361
xyz     pqr     1
 
362
xyz     pqr     8
 
363
xyz     pqr     9
 
364
xyz     pqr     10
 
365
xyz     pqr     2
 
366
xyz     pqr     8
 
367
xyz     pqr     9
 
368
xyz     pqr     10
 
369
xyz     pqr     3
 
370
xyz     pqr     8
 
371
xyz     pqr     9
 
372
xyz     pqr     10
 
373
xyz     pqr     1
 
374
xyz     pqr     8
 
375
xyz     pqr     9
 
376
xyz     pqr     10
 
377
xyz     pqr     2
 
378
xyz     pqr     8
 
379
xyz     pqr     9
 
380
xyz     pqr     10
 
381
xyz     pqr     3
 
382
xyz     pqr     8
 
383
xyz     pqr     9
 
384
xyz     pqr     10
 
385
DROP PROCEDURE sp21;
 
386
drop table res_t21;
 
387
 
 
388
Testcase 3.1.3.30:
 
389
------------------
 
390
 
 
391
Ensure that multiple cases of all possible combinations of the control flow
 
392
statements, nested within multiple compound statements within a stored
 
393
procedure, always act correctly and return the expected result.
 
394
--------------------------------------------------------------------------------
 
395
DROP TABLE IF EXISTS res_tbl;
 
396
DROP PROCEDURE IF EXISTS sp31330;
 
397
create table res_tbl (f1 int, f2 text, f3 blob, f4 date,
 
398
f5 set('one', 'two', 'three', 'four', 'five') default 'one');
 
399
CREATE PROCEDURE sp31330 (path int)
 
400
BEGIN
 
401
declare count int default 1;
 
402
declare var1 text;
 
403
declare var2 blob;
 
404
declare var3 date;
 
405
declare var4 set('one', 'two', 'three', 'four', 'five') DEFAULT 'five';
 
406
case
 
407
when path=1 then
 
408
set var3 = '2000-11-09';
 
409
set var1 = 'flowing through case 1';
 
410
label1: loop
 
411
if count > 5 then
 
412
if var4=1000 then
 
413
set var2 = 'exiting out of case 1 - invalid SET';
 
414
END if;
 
415
if var4='two' then
 
416
set var2 = 'exiting out of case 1';
 
417
END if;
 
418
insert into res_tbl values (1, var1, var2, var3, (count-2));
 
419
leave label1;
 
420
elseif count = 5 then
 
421
set count= count + 2;
 
422
set var4='two';
 
423
iterate label1;
 
424
else
 
425
set count= count + 1;
 
426
END if;
 
427
set var4='one';
 
428
END loop label1;
 
429
when path=2 then
 
430
set var3 = '1989-11-09';
 
431
set var1 = 'flowing through case 2';
 
432
set @count3=0;
 
433
label2: repeat
 
434
set count=count + 1;
 
435
set @count2=1;
 
436
while @count2 <= 5 do
 
437
set @count2 = @count2 + 1;
 
438
END while;
 
439
SELECT @count2;
 
440
set @count3=@count3 + @count2;
 
441
until count > 5
 
442
END repeat label2;
 
443
set var2 = 'exiting out of case 2';
 
444
set var4 = count-3;
 
445
SELECT @count3;
 
446
insert into res_tbl values (2, var1, var2, var3, var4);
 
447
ELSE BEGIN
 
448
set @error_opt='undefined path specified';
 
449
SELECT @error_opt;
 
450
END;
 
451
END case;
 
452
END//
 
453
CALL sp31330();
 
454
ERROR 42000: Incorrect number of arguments for PROCEDURE db_storedproc.sp31330; expected 1, got 0
 
455
CALL sp31330(1);
 
456
SELECT * from res_tbl;
 
457
f1      f2      f3      f4      f5
 
458
1       flowing through case 1  exiting out of case 1   2000-11-09      one,three
 
459
CALL sp31330(2);
 
460
@count2
 
461
6
 
462
@count2
 
463
6
 
464
@count2
 
465
6
 
466
@count2
 
467
6
 
468
@count2
 
469
6
 
470
@count3
 
471
30
 
472
SELECT * from res_tbl;
 
473
f1      f2      f3      f4      f5
 
474
1       flowing through case 1  exiting out of case 1   2000-11-09      one,three
 
475
2       flowing through case 2  exiting out of case 2   1989-11-09      one,two
 
476
CALL sp31330(4);
 
477
@error_opt
 
478
undefined path specified
 
479
DROP PROCEDURE sp31330;
 
480
drop table res_tbl;
 
481
 
 
482
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc
 
483
--------------------------------------------------------------------------------
 
484
DROP DATABASE IF EXISTS db_storedproc;
 
485
DROP DATABASE IF EXISTS db_storedproc_1;
 
486
 
 
487
.                               +++ END OF SCRIPT +++
 
488
--------------------------------------------------------------------------------