~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/suite/funcs_1/r/falcon_storedproc_06.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
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 = falcon;
 
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 = falcon;
 
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 = falcon;
 
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 = falcon;
 
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 = falcon;
 
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 = falcon;
 
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 = falcon;
 
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 = falcon;
 
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 = falcon;
 
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 = falcon;
 
57
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t11;
 
58
 
 
59
Section 3.1.6 - Privilege Checks:
 
60
--------------------------------------------------------------------------------
 
61
USE db_storedproc_1;
 
62
        
 
63
root@localhost  db_storedproc_1
 
64
 
 
65
Testcase 3.1.6.1:
 
66
-----------------
 
67
Ensure that no user may create a stored procedure without the GRANT CREATE
 
68
ROUTINE privilege.
 
69
--------------------------------------------------------------------------------
 
70
create user 'user_1'@'localhost';
 
71
grant all on db_storedproc_1.* to 'user_1'@'localhost';
 
72
revoke create routine on db_storedproc_1.* from 'user_1'@'localhost';
 
73
flush privileges;
 
74
DROP PROCEDURE IF EXISTS sp1;
 
75
connect(localhost,user_1,,db_storedproc_1,MYSQL_PORT,MYSQL_SOCK);
 
76
        
 
77
user_1@localhost        db_storedproc_1
 
78
USE db_storedproc_1;
 
79
CREATE PROCEDURE sp1(v1 char(20))
 
80
BEGIN
 
81
SELECT * from db_storedproc_1.t6 where t6.f2= 'xyz';
 
82
END//
 
83
ERROR 42000: Access denied for user 'user_1'@'localhost' to database 'db_storedproc_1'
 
84
USE db_storedproc_1;
 
85
        
 
86
root@localhost  db_storedproc_1
 
87
GRANT CREATE ROUTINE ON db_storedproc_1.* TO 'user_1'@'localhost';
 
88
connect(localhost,user_1,,db_storedproc_1,MYSQL_PORT,MYSQL_SOCK);
 
89
        
 
90
user_1@localhost        db_storedproc_1
 
91
USE db_storedproc_1;
 
92
CREATE PROCEDURE sp1(v1 char(20))
 
93
BEGIN
 
94
SELECT * from db_storedproc_1.t6 where t6.f2= 'xyz';
 
95
END//
 
96
USE db_storedproc_1;
 
97
        
 
98
root@localhost  db_storedproc_1
 
99
DROP USER 'user_1'@'localhost';
 
100
DROP PROCEDURE sp1;
 
101
 
 
102
Testcase 3.1.6.2:
 
103
-----------------
 
104
Ensure that root always has the GRANT CREATE ROUTINE privilege.
 
105
(checked by other testscases)
 
106
--------------------------------------------------------------------------------
 
107
grant create routine on db_storedproc_1.* to 'user_1'@'localhost';
 
108
flush privileges;
 
109
connect(localhost,user_1,,db_storedproc_1,MYSQL_PORT,MYSQL_SOCK);
 
110
        
 
111
user_1@localhost        db_storedproc_1
 
112
DROP PROCEDURE IF EXISTS sp3;
 
113
DROP FUNCTION IF EXISTS fn1;
 
114
CREATE PROCEDURE sp3(v1 char(20))
 
115
BEGIN
 
116
SELECT * from db_storedproc_1.t6 where t6.f2= 'xyz';
 
117
END//
 
118
CREATE FUNCTION fn1(v1 int) returns int
 
119
BEGIN
 
120
return v1;
 
121
END//
 
122
USE db_storedproc_1;
 
123
        
 
124
root@localhost  db_storedproc_1
 
125
drop user 'user_1'@'localhost';
 
126
DROP PROCEDURE sp3;
 
127
DROP FUNCTION fn1;
 
128
Warnings:
 
129
Error   1133    Can't find any matching row in the user table
 
130
Error   1269    Can't revoke all privileges for one or more of the requested users
 
131
Warning 1405    Failed to revoke all privileges to dropped routine
 
132
 
 
133
Testcase 3.1.6.4:
 
134
-----------------
 
135
Ensure that the default security provision of a stored procedure is SQL SECURITY
 
136
DEFINER.
 
137
--------------------------------------------------------------------------------
 
138
CREATE USER 'user_1'@'localhost';
 
139
grant update on db_storedproc_1.t6 to 'user_1'@'localhost';
 
140
grant execute on db_storedproc_1.* to 'user_1'@'localhost';
 
141
flush privileges;
 
142
USE db_storedproc_1;
 
143
DROP PROCEDURE IF EXISTS sp4;
 
144
CREATE PROCEDURE sp4(v1 char(20))
 
145
BEGIN
 
146
SELECT * from db_storedproc_1.t6 where t6.f2= 'xyz';
 
147
END//
 
148
connect(localhost,user_1,,db_storedproc_1,MYSQL_PORT,MYSQL_SOCK);
 
149
        
 
150
user_1@localhost        db_storedproc_1
 
151
USE db_storedproc_1;
 
152
CALL sp4('a');
 
153
f1      f2      f3      f4      f5      f6
 
154
SELECT SPECIFIC_NAME, ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE,
 
155
ROUTINE_BODY, ROUTINE_DEFINITION, IS_DETERMINISTIC,
 
156
SQL_DATA_ACCESS, SECURITY_TYPE, SQL_MODE, ROUTINE_COMMENT
 
157
FROM information_schema.routines
 
158
WHERE routine_schema LIKE 'db_sto%';
 
159
SPECIFIC_NAME   sp4
 
160
ROUTINE_SCHEMA  db_storedproc_1
 
161
ROUTINE_NAME    sp4
 
162
ROUTINE_TYPE    PROCEDURE
 
163
ROUTINE_BODY    SQL
 
164
ROUTINE_DEFINITION      NULL
 
165
IS_DETERMINISTIC        NO
 
166
SQL_DATA_ACCESS CONTAINS SQL
 
167
SECURITY_TYPE   DEFINER
 
168
SQL_MODE        
 
169
ROUTINE_COMMENT 
 
170
        
 
171
root@localhost  db_storedproc_1
 
172
DROP PROCEDURE sp4;
 
173
DROP USER 'user_1'@'localhost';
 
174
 
 
175
Testcase 3.1.6.5:
 
176
-----------------
 
177
Ensure that a stored procedure defined with SQL SECURITY DEFINER can be
 
178
called/executed by any user, using only the privileges (including database
 
179
access privileges) associated with the user who created the stored procedure.
 
180
--------------------------------------------------------------------------------
 
181
USE db_storedproc_1;
 
182
CREATE TABLE t3165 ( c1 char(20), c2 char(20), c3 date);
 
183
INSERT INTO t3165 VALUES ('inserted', 'outside of SP', NULL);
 
184
create user 'user_1'@'localhost';
 
185
create user 'user_2'@'localhost';
 
186
grant create routine on db_storedproc_1.* to 'user_1'@'localhost';
 
187
grant SELECT on db_storedproc_1.* to 'user_2'@'localhost';
 
188
grant execute on db_storedproc_1.* to 'user_2'@'localhost';
 
189
flush privileges;
 
190
connect(localhost,user_1,,db_storedproc_1,MYSQL_PORT,MYSQL_SOCK);
 
191
        
 
192
user_1@localhost        db_storedproc_1
 
193
CREATE PROCEDURE sp5_s_i () sql security definer
 
194
BEGIN
 
195
SELECT * from db_storedproc_1.t3165;
 
196
insert into db_storedproc_1.t3165 values ('inserted', 'from sp5_s_i', 1000);
 
197
END//
 
198
CREATE PROCEDURE sp5_sel () sql security definer
 
199
BEGIN
 
200
SELECT * from db_storedproc_1.t3165;
 
201
END//
 
202
CREATE PROCEDURE sp5_ins () sql security definer
 
203
BEGIN
 
204
insert into db_storedproc_1.t3165 values ('inserted', 'from sp5_ins', 1000);
 
205
END//
 
206
connect(localhost,user_2,,db_storedproc_1,MYSQL_PORT,MYSQL_SOCK);
 
207
        
 
208
user_2@localhost        db_storedproc_1
 
209
CALL sp5_s_i();
 
210
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't3165'
 
211
CALL sp5_ins();
 
212
ERROR 42000: INSERT command denied to user 'user_1'@'localhost' for table 't3165'
 
213
CALL sp5_sel();
 
214
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't3165'
 
215
        
 
216
root@localhost  db_storedproc_1
 
217
CALL sp5_sel();
 
218
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't3165'
 
219
grant insert on db_storedproc_1.* to 'user_1'@'localhost';
 
220
flush privileges;
 
221
        
 
222
user_2@localhost        db_storedproc_1
 
223
CALL sp5_s_i();
 
224
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't3165'
 
225
CALL sp5_ins();
 
226
CALL sp5_sel();
 
227
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't3165'
 
228
        
 
229
root@localhost  db_storedproc_1
 
230
CALL sp5_sel();
 
231
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't3165'
 
232
grant SELECT on db_storedproc_1.* to 'user_1'@'localhost';
 
233
flush privileges;
 
234
        
 
235
user_2@localhost        db_storedproc_1
 
236
CALL sp5_s_i();
 
237
c1      c2      c3
 
238
inserted        outside of SP   NULL
 
239
inserted        from sp5_ins    2000-10-00
 
240
CALL sp5_ins();
 
241
CALL sp5_sel();
 
242
c1      c2      c3
 
243
inserted        outside of SP   NULL
 
244
inserted        from sp5_ins    2000-10-00
 
245
inserted        from sp5_s_i    2000-10-00
 
246
inserted        from sp5_ins    2000-10-00
 
247
        
 
248
root@localhost  db_storedproc_1
 
249
REVOKE INSERT on db_storedproc_1.* from 'user_1'@'localhost';
 
250
flush privileges;
 
251
        
 
252
user_2@localhost        db_storedproc_1
 
253
CALL sp5_s_i();
 
254
c1      c2      c3
 
255
inserted        outside of SP   NULL
 
256
inserted        from sp5_ins    2000-10-00
 
257
inserted        from sp5_s_i    2000-10-00
 
258
inserted        from sp5_ins    2000-10-00
 
259
ERROR 42000: INSERT command denied to user 'user_1'@'localhost' for table 't3165'
 
260
CALL sp5_ins();
 
261
ERROR 42000: INSERT command denied to user 'user_1'@'localhost' for table 't3165'
 
262
CALL sp5_sel();
 
263
c1      c2      c3
 
264
inserted        outside of SP   NULL
 
265
inserted        from sp5_ins    2000-10-00
 
266
inserted        from sp5_s_i    2000-10-00
 
267
inserted        from sp5_ins    2000-10-00
 
268
        
 
269
root@localhost  db_storedproc_1
 
270
REVOKE SELECT on db_storedproc_1.* from 'user_1'@'localhost';
 
271
flush privileges;
 
272
        
 
273
user_2@localhost        db_storedproc_1
 
274
CALL sp5_s_i();
 
275
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't3165'
 
276
CALL sp5_ins();
 
277
ERROR 42000: INSERT command denied to user 'user_1'@'localhost' for table 't3165'
 
278
CALL sp5_sel();
 
279
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't3165'
 
280
        
 
281
root@localhost  db_storedproc_1
 
282
DROP PROCEDURE sp5_s_i;
 
283
DROP PROCEDURE sp5_sel;
 
284
DROP PROCEDURE sp5_ins;
 
285
DROP TABLE t3165;
 
286
DROP USER 'user_1'@'localhost';
 
287
DROP USER 'user_2'@'localhost';
 
288
 
 
289
Testcase 3.1.6.6:
 
290
-----------------
 
291
Ensure that a stored procedure defined with SQL SECURITY INVOKER can be
 
292
called/executed by any user, using only the privileges (including database
 
293
access privileges) associated with the user executing the stored procedure.
 
294
--------------------------------------------------------------------------------
 
295
USE db_storedproc_1;
 
296
CREATE TABLE t3166 ( c1 char(30) );
 
297
INSERT INTO db_storedproc_1.t3166 VALUES ('inserted outside SP');
 
298
create user 'user_1'@'localhost';
 
299
create user 'user_2'@'localhost';
 
300
GRANT CREATE ROUTINE ON db_storedproc_1.* TO 'user_1'@'localhost';
 
301
GRANT SELECT  ON db_storedproc_1.* TO 'user_2'@'localhost';
 
302
GRANT EXECUTE ON db_storedproc_1.* TO 'user_2'@'localhost';
 
303
FLUSH PRIVILEGES;
 
304
connect(localhost,user_1,,db_storedproc_1,MYSQL_PORT,MYSQL_SOCK);
 
305
        
 
306
user_1@localhost        db_storedproc_1
 
307
CREATE PROCEDURE sp3166_s_i () SQL SECURITY INVOKER
 
308
BEGIN
 
309
SELECT * from db_storedproc_1.t3166;
 
310
insert into db_storedproc_1.t3166 values ('inserted from sp3166_s_i');
 
311
END//
 
312
CREATE PROCEDURE sp3166_sel () SQL SECURITY INVOKER
 
313
BEGIN
 
314
SELECT * from db_storedproc_1.t3166;
 
315
END//
 
316
CREATE PROCEDURE sp3166_ins () SQL SECURITY INVOKER
 
317
BEGIN
 
318
insert into db_storedproc_1.t3166 values ('inserted from sp3166_ins');
 
319
END//
 
320
connect(localhost,user_2,,db_storedproc_1,MYSQL_PORT,MYSQL_SOCK);
 
321
        
 
322
user_2@localhost        db_storedproc_1
 
323
CALL sp3166_s_i();
 
324
c1
 
325
inserted outside SP
 
326
ERROR 42000: INSERT command denied to user 'user_2'@'localhost' for table 't3166'
 
327
CALL sp3166_ins();
 
328
ERROR 42000: INSERT command denied to user 'user_2'@'localhost' for table 't3166'
 
329
CALL sp3166_sel();
 
330
c1
 
331
inserted outside SP
 
332
        
 
333
root@localhost  db_storedproc_1
 
334
CALL sp3166_sel();
 
335
c1
 
336
inserted outside SP
 
337
GRANT INSERT  ON db_storedproc_1.* TO 'user_2'@'localhost';
 
338
FLUSH PRIVILEGES;
 
339
connect(localhost,user_2,,db_storedproc_1,MYSQL_PORT,MYSQL_SOCK);
 
340
        
 
341
user_2@localhost        db_storedproc_1
 
342
CALL sp3166_s_i();
 
343
c1
 
344
inserted outside SP
 
345
CALL sp3166_ins();
 
346
CALL sp3166_sel();
 
347
c1
 
348
inserted outside SP
 
349
inserted from sp3166_s_i
 
350
inserted from sp3166_ins
 
351
        
 
352
root@localhost  db_storedproc_1
 
353
CALL sp3166_sel();
 
354
c1
 
355
inserted outside SP
 
356
inserted from sp3166_s_i
 
357
inserted from sp3166_ins
 
358
REVOKE SELECT ON db_storedproc_1.* FROM 'user_2'@'localhost';
 
359
FLUSH PRIVILEGES;
 
360
connect(localhost,user_2,,db_storedproc_1,MYSQL_PORT,MYSQL_SOCK);
 
361
        
 
362
user_2@localhost        db_storedproc_1
 
363
CALL sp3166_s_i();
 
364
ERROR 42000: SELECT command denied to user 'user_2'@'localhost' for table 't3166'
 
365
CALL sp3166_ins();
 
366
CALL sp3166_sel();
 
367
ERROR 42000: SELECT command denied to user 'user_2'@'localhost' for table 't3166'
 
368
CALL sp3166_s_i();
 
369
c1
 
370
inserted outside SP
 
371
inserted from sp3166_s_i
 
372
inserted from sp3166_ins
 
373
inserted from sp3166_ins
 
374
        
 
375
root@localhost  db_storedproc_1
 
376
REVOKE EXECUTE on db_storedproc_1.* FROM 'user_2'@'localhost';
 
377
FLUSH PRIVILEGES;
 
378
connect(localhost,user_2,,db_storedproc_1,MYSQL_PORT,MYSQL_SOCK);
 
379
        
 
380
user_2@localhost        db_storedproc_1
 
381
CALL sp3166_s_i();
 
382
ERROR 42000: execute command denied to user 'user_2'@'localhost' for routine 'db_storedproc_1.sp3166_s_i'
 
383
CALL sp3166_ins();
 
384
ERROR 42000: execute command denied to user 'user_2'@'localhost' for routine 'db_storedproc_1.sp3166_ins'
 
385
CALL sp3166_sel();
 
386
ERROR 42000: execute command denied to user 'user_2'@'localhost' for routine 'db_storedproc_1.sp3166_sel'
 
387
        
 
388
root@localhost  db_storedproc_1
 
389
DROP PROCEDURE sp3166_s_i;
 
390
DROP PROCEDURE sp3166_sel;
 
391
DROP PROCEDURE sp3166_ins;
 
392
DROP TABLE t3166;
 
393
DROP USER 'user_1'@'localhost';
 
394
DROP USER 'user_2'@'localhost';
 
395
 
 
396
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc
 
397
--------------------------------------------------------------------------------
 
398
DROP DATABASE IF EXISTS db_storedproc;
 
399
DROP DATABASE IF EXISTS db_storedproc_1;
 
400
 
 
401
.                               +++ END OF SCRIPT +++
 
402
--------------------------------------------------------------------------------