~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

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