mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
WL#1366: Use the schema (db) associated with an SP.
Phase 2: Make SPs belong to a DB, and use qualified names. As a side effect, using USE in an SP is no longer allowed. (It just doesn't work otherwise.) include/mysqld_error.h: New error code (USE is no longer allowed in a stored procedure). include/sql_state.h: New error state (USE is no longer allowed in a stored procedure). mysql-test/r/sp-error.result: Updated result for test of USE in SP (not allowed now). mysql-test/r/sp-security.result: Updated test results for new db column and qualified procedured names. mysql-test/r/sp.result: Updated results for USE in SP (as it's no longer allowed), and for new db column in status result. mysql-test/t/sp-error.test: Moved test of USE in SP from sp.test (as it's no longer allowed). mysql-test/t/sp-security.test: Ajusted tests for new db column and qualified procedured names. mysql-test/t/sp.test: Moved test of USE in SP to sp-error.test (as it's no longer allowed). Adjusted tests for new db column in status result. sql/mysql_priv.h: mysql_change_db() now has optional arguments for use by SP with qualified names. sql/share/czech/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/danish/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/dutch/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/english/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/estonian/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/french/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/german/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/greek/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/hungarian/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/italian/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/japanese/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/korean/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/norwegian-ny/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/norwegian/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/polish/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/portuguese/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/romanian/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/russian/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/serbian/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/slovak/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/spanish/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/swedish/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/share/ukrainian/errmsg.txt: New error message: USE is not allowed in a stored procedure. sql/sp.cc: SPs are now "belong" to a DB and may have qualified names. New functions for changing DB ("use") when parsing and invoking SPs. sql/sp.h: New functions for changing DB ("use") when parsing and invoking SPs. sql/sp_cache.cc: Use the qualified name in the SP cache. sql/sp_head.cc: New function for allocating a qualified SP name (used in sql_yacc.yy). Change DB when executing an SP (if needed). Moved thd_mem_root swap functions from sp_head.h. sql/sp_head.h: New function for allocating a qualified SP name (used in sql_yacc.yy). Moved thd_mem_root swap functions to sp_head.cc. sql/sql_db.cc: mysql_change_db() now has optional arguments for use by SP with qualified names (for use when reading an SP from database and executing it); also allow "unusing" a database, i.e. setting thd->thd to "". sql/sql_yacc.yy: Initialize qualfied SP names correctly. USE is no longer allowed in an SP.
This commit is contained in:
@ -8,16 +8,16 @@ create table t1 ( u varchar(64), i int );
|
||||
create procedure stamp(i int)
|
||||
insert into db1_secret.t1 values (user(), i);
|
||||
show procedure status like 'stamp';
|
||||
Name Type Definer Modified Created Security_type Comment
|
||||
stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
|
||||
Db Name Type Definer Modified Created Security_type Comment
|
||||
db1_secret stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
|
||||
call stamp(1);
|
||||
select * from t1;
|
||||
u i
|
||||
root@localhost 1
|
||||
call stamp(2);
|
||||
call db1_secret.stamp(2);
|
||||
select * from db1_secret.t1;
|
||||
ERROR 42000: Access denied for user: 'user1'@'localhost' to database 'db1_secret'
|
||||
call stamp(3);
|
||||
call db1_secret.stamp(3);
|
||||
select * from db1_secret.t1;
|
||||
ERROR 42000: Access denied for user: ''@'localhost' to database 'db1_secret'
|
||||
select * from t1;
|
||||
@ -27,8 +27,8 @@ user1@localhost 2
|
||||
anon@localhost 3
|
||||
alter procedure stamp sql security invoker;
|
||||
show procedure status like 'stamp';
|
||||
Name Type Definer Modified Created Security_type Comment
|
||||
stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER
|
||||
Db Name Type Definer Modified Created Security_type Comment
|
||||
db1_secret stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER
|
||||
call stamp(4);
|
||||
select * from t1;
|
||||
u i
|
||||
@ -36,9 +36,9 @@ root@localhost 1
|
||||
user1@localhost 2
|
||||
anon@localhost 3
|
||||
root@localhost 4
|
||||
call stamp(5);
|
||||
call db1_secret.stamp(5);
|
||||
ERROR 42000: Access denied for user: 'user1'@'localhost' to database 'db1_secret'
|
||||
call stamp(6);
|
||||
call db1_secret.stamp(6);
|
||||
ERROR 42000: Access denied for user: ''@'localhost' to database 'db1_secret'
|
||||
drop database if exists db2;
|
||||
create database db2;
|
||||
@ -73,9 +73,9 @@ s1
|
||||
0
|
||||
2
|
||||
2
|
||||
drop procedure stamp;
|
||||
drop procedure p;
|
||||
drop procedure q;
|
||||
drop procedure db1_secret.stamp;
|
||||
drop procedure db2.p;
|
||||
drop procedure db2.q;
|
||||
use test;
|
||||
drop database db1_secret;
|
||||
drop database db2;
|
||||
|
Reference in New Issue
Block a user