List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:November 9 2007 10:29am
Subject:bk commit into 5.0 tree (kaa:1.2547) BUG#32020
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kaa. When kaa 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@stripped, 2007-11-09 13:29:43+03:00, kaa@polly.(none) +3 -0
  Fix for bug #32020: loading udfs while --skip-grant-tables is enabled
  causes out of memory errors
  
  The code in mysql_create_function() and mysql_drop_function() assumed
  that the only reason for UDFs being uninitialized at that point is an
  out-of-memory error during initialization. However, another possible 
  reason for that is the --skip-grant-tables option in which case UDF 
  initialization is skipped and UDFs are unavailable.
  
  The solution is to check whether mysqld is running with
  --skip-grant-tables and issue a proper error in such a case.

  mysql-test/r/skip_grants.result@stripped, 2007-11-09 13:29:36+03:00, kaa@polly.(none) +5 -0
    Added a test case for bug #32020.

  mysql-test/t/skip_grants.test@stripped, 2007-11-09 13:29:36+03:00, kaa@polly.(none) +12 -0
    Added a test case for bug #32020.

  sql/sql_udf.cc@stripped, 2007-11-09 13:29:36+03:00, kaa@polly.(none) +10 -2
    Issue a proper error when a user tries to CREATE/DROP a UDF 
    on a server running with the --skip-grant-tables option.

diff -Nrup a/mysql-test/r/skip_grants.result b/mysql-test/r/skip_grants.result
--- a/mysql-test/r/skip_grants.result	2007-03-16 11:15:49 +03:00
+++ b/mysql-test/r/skip_grants.result	2007-11-09 13:29:36 +03:00
@@ -70,3 +70,8 @@ count(*)
 select count(*) from information_schema.USER_PRIVILEGES;
 count(*)
 0
+CREATE FUNCTION a RETURNS STRING SONAME '';
+ERROR HY000: Can't initialize function 'a'; UDFs are unavailable with the --skip-grant-tables option
+DROP FUNCTION a;
+ERROR 42000: FUNCTION test.a does not exist
+End of 5.0 tests
diff -Nrup a/mysql-test/t/skip_grants.test b/mysql-test/t/skip_grants.test
--- a/mysql-test/t/skip_grants.test	2007-03-16 11:15:49 +03:00
+++ b/mysql-test/t/skip_grants.test	2007-11-09 13:29:36 +03:00
@@ -116,3 +116,15 @@ select count(*) from information_schema.
 select count(*) from information_schema.SCHEMA_PRIVILEGES;
 select count(*) from information_schema.TABLE_PRIVILEGES;
 select count(*) from information_schema.USER_PRIVILEGES;
+
+#
+# Bug #32020: loading udfs while --skip-grant-tables is enabled causes out of 
+#             memory errors
+#
+
+--error ER_CANT_INITIALIZE_UDF
+CREATE FUNCTION a RETURNS STRING SONAME '';
+--error ER_SP_DOES_NOT_EXIST
+DROP FUNCTION a;
+
+--echo End of 5.0 tests
diff -Nrup a/sql/sql_udf.cc b/sql/sql_udf.cc
--- a/sql/sql_udf.cc	2007-01-03 19:29:34 +03:00
+++ b/sql/sql_udf.cc	2007-11-09 13:29:36 +03:00
@@ -410,7 +410,12 @@ int mysql_create_function(THD *thd,udf_f
 
   if (!initialized)
   {
-    my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
+    if (opt_noacl)
+      my_error(ER_CANT_INITIALIZE_UDF, MYF(0),
+               udf->name.str,
+               "UDFs are unavailable with the --skip-grant-tables option");
+    else
+      my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
     DBUG_RETURN(1);
   }
 
@@ -514,7 +519,10 @@ int mysql_drop_function(THD *thd,const L
   DBUG_ENTER("mysql_drop_function");
   if (!initialized)
   {
-    my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
+    if (opt_noacl)
+      my_error(ER_FUNCTION_NOT_DEFINED, MYF(0), udf_name->str);
+    else
+      my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
     DBUG_RETURN(1);
   }
   rw_wrlock(&THR_LOCK_udf);  
Thread
bk commit into 5.0 tree (kaa:1.2547) BUG#32020Alexey Kopytov9 Nov