~ubuntu-branches/ubuntu/hardy/mysql-dfsg-5.0/hardy-updates

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): sean finney
  • Date: 2007-05-13 12:32:45 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20070513123245-8c3l187dk34cz2ar
Tags: 5.0.41-2
the previous "translation changes" inadvertently introduced unrelated
changes in the package control file.

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