summaryrefslogtreecommitdiff
path: root/mysql-test/t/sp-security.test
diff options
context:
space:
mode:
authorunknown <pem@mysql.comhem.se>2004-03-19 19:01:54 +0100
committerunknown <pem@mysql.comhem.se>2004-03-19 19:01:54 +0100
commitd2ad3cff192de352961ec01f5370821690d7173f (patch)
tree8a8b60eab5553d3fb3d8304e77dadd313b4c77e6 /mysql-test/t/sp-security.test
parentedf2003009c7fd44c6a8b4a9306685357dbbb399 (diff)
downloadmariadb-git-d2ad3cff192de352961ec01f5370821690d7173f.tar.gz
WL#1366: Use the schema (db) associated with an SP.
Phase 3: Made qualified names work for functions as well. mysql-test/r/sp-security.result: New testcases for functions with qualified names. mysql-test/t/sp-security.test: New testcases for functions with qualified names. sql/item_func.cc: Added error handling for stored function, if it doesn't exist. sql/item_func.h: Set null_value if execution of a stored function fails. sql/mysql_priv.h: Reverted previous change: No optional args for mysql_change_db(). (SPs use a specially tailored function instead.) sql/sp.cc: Copied mysql_change_db() from sql_db.cc and modified specially for SPs. sql/sp_head.cc: Fixed error handling for errors in functions during query/statement execution. sql/sql_db.cc: Reverted previous change: No optional args for mysql_change_db(). (SPs use a specially tailored function instead.) sql/sql_yacc.yy: Reworked the stored function/UDF invokation parsing and added qualified names for stored functions. UDFs now have precedence over stored functions (whith unqualified name). When using an unqualified name, only IDENT_sys is allowed (i.e. no unreserved keywords), since we get unresolvable reduce/reduce conflicts otherwise.
Diffstat (limited to 'mysql-test/t/sp-security.test')
-rw-r--r--mysql-test/t/sp-security.test20
1 files changed, 18 insertions, 2 deletions
diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test
index 2d089e72d0b..ae977684129 100644
--- a/mysql-test/t/sp-security.test
+++ b/mysql-test/t/sp-security.test
@@ -21,15 +21,20 @@ use db1_secret;
create table t1 ( u varchar(64), i int );
-# Our test procedure
+# A test procedure and function
create procedure stamp(i int)
insert into db1_secret.t1 values (user(), i);
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
show procedure status like 'stamp';
+create function db() returns varchar(64) return database();
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+show function status like 'db';
+
# root can, of course
call stamp(1);
select * from t1;
+select db();
connect (con2user1,localhost,user1,,);
connect (con3anon,localhost,anon,,);
@@ -41,6 +46,7 @@ connection con2user1;
# This should work...
call db1_secret.stamp(2);
+select db1_secret.db();
# ...but not this
--error 1044
@@ -53,6 +59,7 @@ connection con3anon;
# This should work...
call db1_secret.stamp(3);
+select db1_secret.db();
# ...but not this
--error 1044
@@ -71,9 +78,14 @@ alter procedure stamp sql security invoker;
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
show procedure status like 'stamp';
+alter function db sql security invoker;
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+show function status like 'db';
+
# root still can
call stamp(4);
select * from t1;
+select db();
#
# User1 cannot
@@ -83,6 +95,8 @@ connection con2user1;
# This should not work
--error 1044
call db1_secret.stamp(5);
+--error 1044
+select db1_secret.db();
#
# Anonymous cannot
@@ -92,7 +106,8 @@ connection con3anon;
# This should not work
--error 1044
call db1_secret.stamp(6);
-
+--error 1044
+select db1_secret.db();
#
# BUG#2777
@@ -149,6 +164,7 @@ select * from t2;
# Clean up
connection con1root;
drop procedure db1_secret.stamp;
+drop function db1_secret.db;
drop procedure db2.p;
drop procedure db2.q;
use test;