List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:August 10 2005 4:29am
Subject:bk commit into 5.0 tree (jimw:1.1959) BUG#12318
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1959 05/08/09 19:29:06 jimw@stripped +4 -0
  Avoid spurious error when restoring INFORMATION_SCHEMA as the current 
  database after failing to execute a stored procedure in an inaccessible
  database. (Bug #12318)

  sql/sql_db.cc
    1.110 05/08/09 19:29:02 jimw@stripped +4 -1
    Add note that sp_change_db() should be checked when mysql_change_db()
    is modified.

  sql/sp.cc
    1.87 05/08/09 19:29:02 jimw@stripped +25 -8
    Handle information_schema in sp_change_db().

  mysql-test/t/sp-security.test
    1.21 05/08/09 19:29:02 jimw@stripped +36 -0
    Add new regression test

  mysql-test/r/sp-security.result
    1.19 05/08/09 19:29:02 jimw@stripped +13 -0
    Add new results

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-5.0-12318

--- 1.109/sql/sql_db.cc	2005-05-20 14:31:13 -07:00
+++ 1.110/sql/sql_db.cc	2005-08-09 19:29:02 -07:00
@@ -1010,7 +1010,10 @@
     in ::exec_event() methods of log_event.cc).
 
     This function does not send the error message to the client, if that
-    should be sent to the client, call net_send_error after this function 
+    should be sent to the client, call net_send_error after this function
+
+    There is a similar function called sp_change_db() in sp.cc -- make sure
+    you double-check whether to make changes there like those you make here!
 
   RETURN VALUES
     0	ok

--- 1.18/mysql-test/r/sp-security.result	2005-08-02 20:37:27 -07:00
+++ 1.19/mysql-test/r/sp-security.result	2005-08-09 19:29:02 -07:00
@@ -236,3 +236,16 @@
 drop procedure bug7291_0;
 REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1@localhost;
 drop user user1@localhost;
+drop database if exists mysqltest_1;
+create database mysqltest_1;
+create procedure mysqltest_1.p1()
+begin
+select 1 from dual;
+end//
+grant usage on *.* to mysqltest_1@localhost;
+call mysqltest_1.p1();
+ERROR 42000: execute command denied to user 'mysqltest_1'@'localhost' for routine
'mysqltest_1.p1'
+drop procedure mysqltest_1.p1;
+drop database mysqltest_1;
+revoke usage on *.* from mysqltest_1@localhost;
+drop user mysqltest_1@localhost;

--- 1.20/mysql-test/t/sp-security.test	2005-08-02 20:37:27 -07:00
+++ 1.21/mysql-test/t/sp-security.test	2005-08-09 19:29:02 -07:00
@@ -371,3 +371,39 @@
 disconnect user1;
 REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1@localhost;
 drop user user1@localhost;
+
+#
+# Bug #12318: Wrong error message when accessing an inaccessible stored
+# procedure in another database when the current database is
+# information_schema.
+# 
+
+--disable_warnings
+drop database if exists mysqltest_1;
+--enable_warnings
+
+create database mysqltest_1;
+delimiter //;
+create procedure mysqltest_1.p1()
+begin
+   select 1 from dual;
+end//
+delimiter ;//
+
+grant usage on *.* to mysqltest_1@localhost;
+
+connect (n1,localhost,mysqltest_1,,information_schema,$MASTER_MYPORT,$MASTER_MYSOCK);
+connection n1;
+--error 1370
+call mysqltest_1.p1();
+disconnect n1;
+
+connection default;
+
+drop procedure mysqltest_1.p1;
+drop database mysqltest_1;
+
+revoke usage on *.* from mysqltest_1@localhost;
+drop user mysqltest_1@localhost;
+
+# End of 5.0 bugs.

--- 1.86/sql/sp.cc	2005-08-03 03:13:59 -07:00
+++ 1.87/sql/sp.cc	2005-08-09 19:29:02 -07:00
@@ -1657,6 +1657,7 @@
   char *dbname=my_strdup((char*) name,MYF(MY_WME));
   char	path[FN_REFLEN];
   HA_CREATE_INFO create;
+  bool schema_db= 0;
   DBUG_ENTER("sp_change_db");
   DBUG_PRINT("enter", ("db: %s, no_access_check: %d", name, no_access_check));
 
@@ -1673,6 +1674,13 @@
 
   if (dbname && db_length)
   {
+    if (!my_strcasecmp(system_charset_info, dbname,
+                       information_schema_name.str))
+    {
+      schema_db= 1;
+      goto end;
+    }
+
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
     if (! no_access_check)
     {
@@ -1711,18 +1719,27 @@
     }
   }
 
+end:
   x_free(thd->db);
-  thd->db=dbname;				// THD::~THD will free this
-  thd->db_length=db_length;
+  thd->db= dbname;				// THD::~THD will free this
+  thd->db_length= db_length;
 
   if (dbname && db_length)
   {
-    strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE);
-    load_db_opt(thd, path, &create);
-    thd->db_charset= create.default_table_charset ?
-      create.default_table_charset :
-      thd->variables.collation_server;
-    thd->variables.collation_database= thd->db_charset;
+    if (schema_db)
+    {
+      thd->db_charset= system_charset_info;
+      thd->variables.collation_database= system_charset_info;
+    }
+    else
+    {
+      strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE);
+      load_db_opt(thd, path, &create);
+      thd->db_charset= create.default_table_charset ?
+        create.default_table_charset :
+        thd->variables.collation_server;
+      thd->variables.collation_database= thd->db_charset;
+    }
   }
   DBUG_RETURN(0);
 }
Thread
bk commit into 5.0 tree (jimw:1.1959) BUG#12318Jim Winstead10 Aug