Debian Codegraph @

mysql-test/suite/funcs_1/r/innodb_storedproc_06.result

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