~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/suite/funcs_1/r/innodb_storedproc_10.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 = innodb;
 
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 = innodb;
 
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 = innodb;
 
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 = innodb;
 
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 = innodb;
 
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 = innodb;
 
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 = innodb;
 
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 = innodb;
 
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 = innodb;
 
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 = innodb;
 
55
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t11;
 
56
 
 
57
Section 3.1.10 - CALL checks:
 
58
--------------------------------------------------------------------------------
 
59
USE db_storedproc;
 
60
 
 
61
Testcase 3.1.10.2 + 3.1.10.5:
 
62
-----------------------------
 
63
 
 
64
2. Ensure that a procedure cannot be called if the appropriate privileges do not
 
65
exist.
 
66
5. Ensure that a function cannot be executed if the appropriate privileges do
 
67
not exist.
 
68
--------------------------------------------------------------------------------
 
69
DROP PROCEDURE IF EXISTS sp31102;
 
70
DROP FUNCTION  IF EXISTS fn31105;
 
71
create user 'user_1'@'localhost';
 
72
create user 'user_2'@'localhost';
 
73
GRANT CREATE ROUTINE ON db_storedproc.* TO 'user_1'@'localhost';
 
74
GRANT SELECT         ON db_storedproc.* TO 'user_2'@'localhost';
 
75
FLUSH PRIVILEGES;
 
76
connect(localhost,user_1,,db_storedproc,MYSQL_PORT,MYSQL_SOCK);
 
77
        
 
78
user_1@localhost        db_storedproc
 
79
CREATE PROCEDURE sp31102 () SQL SECURITY INVOKER
 
80
BEGIN
 
81
SELECT * FROM db_storedproc.t1 WHERE f4=-5000 LIMIT 1;
 
82
END//
 
83
CREATE FUNCTION fn31105(n INT) RETURNS INT
 
84
BEGIN
 
85
DECLARE res INT;
 
86
SET res = n * n;
 
87
RETURN res;
 
88
END//
 
89
connect(localhost,user_2,,db_storedproc,MYSQL_PORT,MYSQL_SOCK);
 
90
        
 
91
user_2@localhost        db_storedproc
 
92
CALL sp31102();
 
93
ERROR 42000: execute command denied to user 'user_2'@'localhost' for routine 'db_storedproc.sp31102'
 
94
SELECT fn31105( 9 );
 
95
ERROR 42000: execute command denied to user 'user_2'@'localhost' for routine 'db_storedproc.fn31105'
 
96
connection default;
 
97
USE db_storedproc;
 
98
        
 
99
root@localhost  db_storedproc
 
100
CALL sp31102();
 
101
f1      f2      f3      f4      f5      f6
 
102
a`      a`      1000-01-01      -5000   a`      -5000
 
103
SELECT fn31105( 9 );
 
104
fn31105( 9 )
 
105
81
 
106
GRANT EXECUTE ON db_storedproc.* TO 'user_2'@'localhost';
 
107
FLUSH PRIVILEGES;
 
108
connect(localhost,user_2,,db_storedproc,MYSQL_PORT,MYSQL_SOCK);
 
109
        
 
110
user_2@localhost        db_storedproc
 
111
CALL sp31102();
 
112
f1      f2      f3      f4      f5      f6
 
113
a`      a`      1000-01-01      -5000   a`      -5000
 
114
SELECT fn31105( 9 );
 
115
fn31105( 9 )
 
116
81
 
117
connection default;
 
118
USE db_storedproc;
 
119
        
 
120
root@localhost  db_storedproc
 
121
REVOKE EXECUTE ON db_storedproc.* FROM 'user_2'@'localhost';
 
122
FLUSH PRIVILEGES;
 
123
CALL sp31102();
 
124
f1      f2      f3      f4      f5      f6
 
125
a`      a`      1000-01-01      -5000   a`      -5000
 
126
SELECT fn31105( 9 );
 
127
fn31105( 9 )
 
128
81
 
129
connect(localhost,user_2,,db_storedproc,MYSQL_PORT,MYSQL_SOCK);
 
130
        
 
131
user_2@localhost        db_storedproc
 
132
CALL sp31102();
 
133
ERROR 42000: execute command denied to user 'user_2'@'localhost' for routine 'db_storedproc.sp31102'
 
134
SELECT fn31105( 9 );
 
135
ERROR 42000: execute command denied to user 'user_2'@'localhost' for routine 'db_storedproc.fn31105'
 
136
USE db_storedproc;
 
137
        
 
138
root@localhost  db_storedproc
 
139
DROP PROCEDURE sp31102;
 
140
DROP FUNCTION  fn31105;
 
141
DROP USER 'user_1'@'localhost';
 
142
DROP USER 'user_2'@'localhost';
 
143
 
 
144
Testcase 3.1.10.3:
 
145
------------------
 
146
 
 
147
Ensure that a function can never be called.
 
148
--------------------------------------------------------------------------------
 
149
DROP FUNCTION IF EXISTS fn1;
 
150
CREATE FUNCTION fn1(a int) returns int
 
151
BEGIN
 
152
set @b = 0.9 * a;
 
153
return @b;
 
154
END//
 
155
CALL fn1();
 
156
ERROR 42000: PROCEDURE db_storedproc.fn1 does not exist
 
157
DROP FUNCTION fn1;
 
158
 
 
159
Testcase 3.1.10.6:
 
160
------------------
 
161
 
 
162
Ensure that a procedure can never be executed.
 
163
--------------------------------------------------------------------------------
 
164
DROP PROCEDURE IF EXISTS sp1;
 
165
DROP FUNCTION IF EXISTS sp1;
 
166
CREATE PROCEDURE sp1()
 
167
BEGIN
 
168
SELECT * from t10;
 
169
END//
 
170
SELECT sp1();
 
171
ERROR 42000: FUNCTION db_storedproc.sp1 does not exist
 
172
DROP PROCEDURE sp1;
 
173
 
 
174
Testcase 3.1.10.7:
 
175
------------------
 
176
 
 
177
Ensure that the ROW_COUNT() SQL function always returns the correct number of
 
178
rows affected by the execution of a stored procedure.
 
179
--------------------------------------------------------------------------------
 
180
DROP PROCEDURE IF EXISTS sp_ins_1;
 
181
DROP PROCEDURE IF EXISTS sp_ins_3;
 
182
DROP PROCEDURE IF EXISTS sp_upd;
 
183
DROP PROCEDURE IF EXISTS sp_ins_upd;
 
184
DROP PROCEDURE IF EXISTS sp_del;
 
185
DROP PROCEDURE IF EXISTS sp_with_rowcount;
 
186
CREATE TABLE temp(f1 CHAR(20),f2 CHAR(25),f3 DATE,f4 INT,f5 CHAR(25),f6 INT);
 
187
INSERT INTO temp SELECT * FROM t10;
 
188
CREATE PROCEDURE sp_ins_1()
 
189
BEGIN
 
190
INSERT INTO temp VALUES ('abc', 'abc', '20051003', 100, 'uvw', 1000);
 
191
END//
 
192
CREATE PROCEDURE sp_ins_3()
 
193
BEGIN
 
194
INSERT INTO temp VALUES  ('abc', 'xyz', '19490523',   100, 'uvw', 1000);
 
195
INSERT INTO temp VALUES  ('abc', 'xyz', '1989-11-09', 100, 'uvw', 1000);
 
196
INSERT INTO temp VALUES  ('abc', 'xyz', '2005-10-24', 100, 'uvw', 1000);
 
197
END//
 
198
CREATE PROCEDURE sp_upd()
 
199
BEGIN
 
200
UPDATE temp SET temp.f1 = 'updated' WHERE temp.f1 ='abc';
 
201
END//
 
202
CREATE PROCEDURE sp_ins_upd()
 
203
BEGIN
 
204
BEGIN
 
205
INSERT INTO temp VALUES  ('qwe', 'abc', '1989-11-09', 100, 'uvw', 1000);
 
206
INSERT INTO temp VALUES  ('qwe', 'xyz', '1998-03-26', 100, 'uvw', 1000);
 
207
INSERT INTO temp VALUES  ('qwe', 'abc', '2000-11-09', 100, 'uvw', 1000);
 
208
INSERT INTO temp VALUES  ('qwe', 'abc', '2005-11-07', 100, 'uvw', 1000);
 
209
END;
 
210
SELECT COUNT( f1 ), f1 FROM temp GROUP BY f1;
 
211
UPDATE temp SET temp.f1 = 'updated_2' WHERE temp.f1 ='qwe' AND temp.f2 = 'abc';
 
212
END//
 
213
CREATE PROCEDURE sp_del()
 
214
BEGIN
 
215
DELETE FROM temp WHERE temp.f1 ='qwe' OR temp.f1 = 'updated_2';
 
216
END//
 
217
CREATE PROCEDURE sp_with_rowcount()
 
218
BEGIN
 
219
BEGIN
 
220
INSERT INTO temp VALUES  ('qwe', 'abc', '1989-11-09', 100, 'uvw', 1000),
 
221
('qwe', 'xyz', '1998-03-26', 100, 'uvw', 1000),
 
222
('qwe', 'abc', '2000-11-09', 100, 'uvw', 1000),
 
223
('qwe', 'xyz', '2005-11-07', 100, 'uvw', 1000);
 
224
END;
 
225
SELECT row_count() AS 'row_count() after insert';
 
226
SELECT row_count() AS 'row_count() after select row_count()';
 
227
SELECT f1,f2,f3 FROM temp ORDER BY f1,f2,f3;
 
228
UPDATE temp SET temp.f1 = 'updated_2' WHERE temp.f2 = 'abc';
 
229
SELECT row_count() AS 'row_count() after update';
 
230
SELECT f1,f2,f3 FROM temp ORDER BY f1,f2,f3;
 
231
DELETE FROM temp WHERE temp.f1 = 'updated_2';
 
232
SELECT row_count() AS 'row_count() after delete';
 
233
END//
 
234
CALL sp_ins_1();
 
235
SELECT row_count();
 
236
row_count()
 
237
1
 
238
SELECT * FROM temp;
 
239
f1      f2      f3      f4      f5      f6
 
240
a^aaaaaaaa      a^aaaaaaaa      1000-01-09      -4992   a^aaaaaaaa      -4992
 
241
a_aaaaaaaaa     a_aaaaaaaaa     1000-01-10      -4991   a_aaaaaaaaa     -4991
 
242
a`      a`      1000-01-01      -5000   a`      -5000
 
243
aaa     aaa     1000-01-02      -4999   aaa     -4999
 
244
abaa    abaa    1000-01-03      -4998   abaa    -4998
 
245
abc     abc     2005-10-03      100     uvw     1000
 
246
acaaa   acaaa   1000-01-04      -4997   acaaa   -4997
 
247
adaaaa  adaaaa  1000-01-05      -4996   adaaaa  -4996
 
248
aeaaaaa aeaaaaa 1000-01-06      -4995   aeaaaaa -4995
 
249
afaaaaaa        afaaaaaa        1000-01-07      -4994   afaaaaaa        -4994
 
250
agaaaaaaa       agaaaaaaa       1000-01-08      -4993   agaaaaaaa       -4993
 
251
CALL sp_ins_3();
 
252
SELECT row_count();
 
253
row_count()
 
254
1
 
255
SELECT * FROM temp;
 
256
f1      f2      f3      f4      f5      f6
 
257
a^aaaaaaaa      a^aaaaaaaa      1000-01-09      -4992   a^aaaaaaaa      -4992
 
258
a_aaaaaaaaa     a_aaaaaaaaa     1000-01-10      -4991   a_aaaaaaaaa     -4991
 
259
a`      a`      1000-01-01      -5000   a`      -5000
 
260
aaa     aaa     1000-01-02      -4999   aaa     -4999
 
261
abaa    abaa    1000-01-03      -4998   abaa    -4998
 
262
abc     abc     2005-10-03      100     uvw     1000
 
263
abc     xyz     1949-05-23      100     uvw     1000
 
264
abc     xyz     1989-11-09      100     uvw     1000
 
265
abc     xyz     2005-10-24      100     uvw     1000
 
266
acaaa   acaaa   1000-01-04      -4997   acaaa   -4997
 
267
adaaaa  adaaaa  1000-01-05      -4996   adaaaa  -4996
 
268
aeaaaaa aeaaaaa 1000-01-06      -4995   aeaaaaa -4995
 
269
afaaaaaa        afaaaaaa        1000-01-07      -4994   afaaaaaa        -4994
 
270
agaaaaaaa       agaaaaaaa       1000-01-08      -4993   agaaaaaaa       -4993
 
271
CALL sp_upd();
 
272
SELECT row_count();
 
273
row_count()
 
274
4
 
275
SELECT * FROM temp;
 
276
f1      f2      f3      f4      f5      f6
 
277
a^aaaaaaaa      a^aaaaaaaa      1000-01-09      -4992   a^aaaaaaaa      -4992
 
278
a_aaaaaaaaa     a_aaaaaaaaa     1000-01-10      -4991   a_aaaaaaaaa     -4991
 
279
a`      a`      1000-01-01      -5000   a`      -5000
 
280
aaa     aaa     1000-01-02      -4999   aaa     -4999
 
281
abaa    abaa    1000-01-03      -4998   abaa    -4998
 
282
acaaa   acaaa   1000-01-04      -4997   acaaa   -4997
 
283
adaaaa  adaaaa  1000-01-05      -4996   adaaaa  -4996
 
284
aeaaaaa aeaaaaa 1000-01-06      -4995   aeaaaaa -4995
 
285
afaaaaaa        afaaaaaa        1000-01-07      -4994   afaaaaaa        -4994
 
286
agaaaaaaa       agaaaaaaa       1000-01-08      -4993   agaaaaaaa       -4993
 
287
updated abc     2005-10-03      100     uvw     1000
 
288
updated xyz     1949-05-23      100     uvw     1000
 
289
updated xyz     1989-11-09      100     uvw     1000
 
290
updated xyz     2005-10-24      100     uvw     1000
 
291
CALL sp_ins_upd();
 
292
COUNT( f1 )     f1
 
293
1       aaa
 
294
1       abaa
 
295
1       acaaa
 
296
1       adaaaa
 
297
1       aeaaaaa
 
298
1       afaaaaaa
 
299
1       agaaaaaaa
 
300
1       a^aaaaaaaa
 
301
1       a_aaaaaaaaa
 
302
1       a`
 
303
4       qwe
 
304
4       updated
 
305
SELECT row_count();
 
306
row_count()
 
307
3
 
308
SELECT * FROM temp;
 
309
f1      f2      f3      f4      f5      f6
 
310
a^aaaaaaaa      a^aaaaaaaa      1000-01-09      -4992   a^aaaaaaaa      -4992
 
311
a_aaaaaaaaa     a_aaaaaaaaa     1000-01-10      -4991   a_aaaaaaaaa     -4991
 
312
a`      a`      1000-01-01      -5000   a`      -5000
 
313
aaa     aaa     1000-01-02      -4999   aaa     -4999
 
314
abaa    abaa    1000-01-03      -4998   abaa    -4998
 
315
acaaa   acaaa   1000-01-04      -4997   acaaa   -4997
 
316
adaaaa  adaaaa  1000-01-05      -4996   adaaaa  -4996
 
317
aeaaaaa aeaaaaa 1000-01-06      -4995   aeaaaaa -4995
 
318
afaaaaaa        afaaaaaa        1000-01-07      -4994   afaaaaaa        -4994
 
319
agaaaaaaa       agaaaaaaa       1000-01-08      -4993   agaaaaaaa       -4993
 
320
qwe     xyz     1998-03-26      100     uvw     1000
 
321
updated abc     2005-10-03      100     uvw     1000
 
322
updated xyz     1949-05-23      100     uvw     1000
 
323
updated xyz     1989-11-09      100     uvw     1000
 
324
updated xyz     2005-10-24      100     uvw     1000
 
325
updated_2       abc     1989-11-09      100     uvw     1000
 
326
updated_2       abc     2000-11-09      100     uvw     1000
 
327
updated_2       abc     2005-11-07      100     uvw     1000
 
328
CALL sp_del();
 
329
SELECT row_count();
 
330
row_count()
 
331
4
 
332
SELECT * FROM temp;
 
333
f1      f2      f3      f4      f5      f6
 
334
a^aaaaaaaa      a^aaaaaaaa      1000-01-09      -4992   a^aaaaaaaa      -4992
 
335
a_aaaaaaaaa     a_aaaaaaaaa     1000-01-10      -4991   a_aaaaaaaaa     -4991
 
336
a`      a`      1000-01-01      -5000   a`      -5000
 
337
aaa     aaa     1000-01-02      -4999   aaa     -4999
 
338
abaa    abaa    1000-01-03      -4998   abaa    -4998
 
339
acaaa   acaaa   1000-01-04      -4997   acaaa   -4997
 
340
adaaaa  adaaaa  1000-01-05      -4996   adaaaa  -4996
 
341
aeaaaaa aeaaaaa 1000-01-06      -4995   aeaaaaa -4995
 
342
afaaaaaa        afaaaaaa        1000-01-07      -4994   afaaaaaa        -4994
 
343
agaaaaaaa       agaaaaaaa       1000-01-08      -4993   agaaaaaaa       -4993
 
344
updated abc     2005-10-03      100     uvw     1000
 
345
updated xyz     1949-05-23      100     uvw     1000
 
346
updated xyz     1989-11-09      100     uvw     1000
 
347
updated xyz     2005-10-24      100     uvw     1000
 
348
DELETE FROM temp;
 
349
CALL sp_with_rowcount();
 
350
row_count() after insert
 
351
4
 
352
row_count() after select row_count()
 
353
-1
 
354
f1      f2      f3
 
355
qwe     abc     1989-11-09
 
356
qwe     abc     2000-11-09
 
357
qwe     xyz     1998-03-26
 
358
qwe     xyz     2005-11-07
 
359
row_count() after update
 
360
2
 
361
f1      f2      f3
 
362
qwe     xyz     1998-03-26
 
363
qwe     xyz     2005-11-07
 
364
updated_2       abc     1989-11-09
 
365
updated_2       abc     2000-11-09
 
366
row_count() after delete
 
367
2
 
368
SELECT row_count();
 
369
row_count()
 
370
-1
 
371
SELECT * FROM temp;
 
372
f1      f2      f3      f4      f5      f6
 
373
qwe     xyz     1998-03-26      100     uvw     1000
 
374
qwe     xyz     2005-11-07      100     uvw     1000
 
375
DROP PROCEDURE sp_ins_1;
 
376
DROP PROCEDURE sp_ins_3;
 
377
DROP PROCEDURE sp_upd;
 
378
DROP PROCEDURE sp_ins_upd;
 
379
DROP PROCEDURE sp_del;
 
380
DROP PROCEDURE sp_with_rowcount;
 
381
DROP TABLE temp;
 
382
 
 
383
Testcase 3.1.10.8:
 
384
------------------
 
385
 
 
386
Ensure that the mysql_affected_rows() C API function always returns the correct 
 
387
number of rows affected by the execution of a stored procedure.
 
388
--------------------------------------------------------------------------------
 
389
 
 
390
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc
 
391
--------------------------------------------------------------------------------
 
392
DROP DATABASE IF EXISTS db_storedproc;
 
393
DROP DATABASE IF EXISTS db_storedproc_1;
 
394
 
 
395
.                               +++ END OF SCRIPT +++
 
396
--------------------------------------------------------------------------------