From 43aefd66fdda1310abefefd724dbb23c2c701ce8 Mon Sep 17 00:00:00 2001
From: "pem@mysql.comhem.se" <>
Date: Tue, 23 Nov 2004 19:19:09 +0100
Subject: [PATCH] Fix compiler warnings on some systems. (Unused variables)
 Fixed bug in DROP FUNCTION for UDFs. Note: It still doesn't work properly,
 but that bug is somewhere else.

---
 sql/sp.cc        |  3 ++-
 sql/sql_parse.cc | 39 +++++++++++++++++++--------------------
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/sql/sp.cc b/sql/sp.cc
index 5798eedbad9..a39380d7276 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -1153,7 +1153,6 @@ sp_change_db(THD *thd, char *name, bool no_access_check)
   int length, db_length;
   char *dbname=my_strdup((char*) name,MYF(MY_WME));
   char	path[FN_REFLEN];
-  ulong db_access;
   HA_CREATE_INFO create;
   DBUG_ENTER("sp_change_db");
   DBUG_PRINT("enter", ("db: %s, no_access_check: %d", name, no_access_check));
@@ -1174,6 +1173,8 @@ sp_change_db(THD *thd, char *name, bool no_access_check)
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
     if (! no_access_check)
     {
+      ulong db_access;
+
       if (test_all_bits(thd->master_access,DB_ACLS))
 	db_access=DB_ACLS;
       else
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 7781ceac9e2..8f4e922416b 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3339,16 +3339,15 @@ mysql_execute_command(THD *thd)
   }
   case SQLCOM_CREATE_FUNCTION:                  // UDF function
   {
-    sp_head *sph;
     if (check_access(thd,INSERT_ACL,"mysql",0,1,0))
       break;
 #ifdef HAVE_DLOPEN
-    if ((sph= sp_find_function(thd, lex->spname)))
+    if (sp_find_function(thd, lex->spname))
     {
       my_error(ER_UDF_EXISTS, MYF(0), lex->spname->m_name.str);
       goto error;
     }
-    if (!(res = mysql_create_function(thd,&lex->udf)))
+    if (!(res = mysql_create_function(thd, &lex->udf)))
       send_ok(thd);
 #else
     res= TRUE;
@@ -3800,35 +3799,35 @@ mysql_execute_command(THD *thd)
       else
 	sp= sp_find_function(thd, lex->spname);
       mysql_reset_errors(thd);
-      if (! sp)
-	result= SP_KEY_NOT_FOUND;
-      else
+      if (sp)
       {
 	if (check_sp_definer_access(thd, sp))
           goto error;
 	if (lex->sql_command == SQLCOM_DROP_PROCEDURE)
 	  result= sp_drop_procedure(thd, lex->spname);
 	else
-	{
 	  result= sp_drop_function(thd, lex->spname);
+      }
+      else
+      {
 #ifdef HAVE_DLOPEN
-	  if (result == SP_KEY_NOT_FOUND)
-	  {
-	    udf_func *udf = find_udf(lex->spname->m_name.str,
-				     lex->spname->m_name.length);
-	    if (udf)
+	if (lex->sql_command == SQLCOM_DROP_FUNCTION)
+	{
+          udf_func *udf = find_udf(lex->spname->m_name.str,
+                                   lex->spname->m_name.length);
+          if (udf)
+          {
+	    if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 0))
+	      goto error;
+	    if (!(res = mysql_drop_function(thd, &lex->spname->m_name)))
 	    {
-	      if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 0))
-		goto error;
-	      if (!(res = mysql_drop_function(thd,&lex->spname->m_name)))
-	      {
-		send_ok(thd);
-		break;
-	      }
+	      send_ok(thd);
+	      break;
 	    }
 	  }
-#endif
 	}
+#endif
+	result= SP_KEY_NOT_FOUND;
       }
       res= result;
       switch (result)
-- 
2.30.9