List:Commits« Previous MessageNext Message »
From:marc.alff Date:March 13 2008 12:03am
Subject:bk commit into 5.0 tree (malff:1.2604) BUG#31767
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of malff.  When malff 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, 2008-03-12 18:03:23-06:00, malff@stripped. +9 -0
  Bug#31767 (DROP FUNCTION name resolution)
  
  Before this fix,
  DROP FUNCTION <db>.<name> could drop a user defined function named <name>.
  
  The resolution of a <name> to either a UDF or a stored function was
  different in the following statements:
  - DROP FUNCTION <name>
  - SELECT <name>(...)
  
  With this fix, the implementation of DROP FUNCTION has been changed,
  so that:
  - DROP FUNCTION <db>.<name> only drop the stored function <db>.<name>
  - DROP FUNCTION <name> resolve the <name> using rules consistent
  with the SELECT <name>() statement.

  mysql-test/r/sp-error.result@stripped, 2008-03-12 18:01:29-06:00, malff@stripped. +2 -2
    Bug#31767 (DROP FUNCTION name resolution)

  mysql-test/r/sp-vars.result@stripped, 2008-03-12 18:01:29-06:00, malff@stripped. +2 -2
    Bug#31767 (DROP FUNCTION name resolution)

  mysql-test/r/sp.result@stripped, 2008-03-12 18:01:30-06:00, malff@stripped. +2 -2
    Bug#31767 (DROP FUNCTION name resolution)

  mysql-test/r/strict.result@stripped, 2008-03-12 18:01:30-06:00, malff@stripped. +1 -1
    Bug#31767 (DROP FUNCTION name resolution)

  mysql-test/r/udf.result@stripped, 2008-03-12 18:01:30-06:00, malff@stripped. +46 -0
    Bug#31767 (DROP FUNCTION name resolution)

  mysql-test/r/view.result@stripped, 2008-03-12 18:01:30-06:00, malff@stripped. +1 -1
    Bug#31767 (DROP FUNCTION name resolution)

  mysql-test/r/warnings.result@stripped, 2008-03-12 18:01:30-06:00, malff@stripped. +3 -3
    Bug#31767 (DROP FUNCTION name resolution)

  mysql-test/t/udf.test@stripped, 2008-03-12 18:01:30-06:00, malff@stripped. +69 -0
    Bug#31767 (DROP FUNCTION name resolution)

  sql/sql_parse.cc@stripped, 2008-03-12 18:01:30-06:00, malff@stripped. +49 -30
    Bug#31767 (DROP FUNCTION name resolution)

diff -Nrup a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
--- a/mysql-test/r/sp-error.result	2008-01-23 13:26:38 -07:00
+++ b/mysql-test/r/sp-error.result	2008-03-12 18:01:29 -06:00
@@ -45,7 +45,7 @@ call foo()|
 ERROR 42000: PROCEDURE test.foo does not exist
 drop procedure if exists foo|
 Warnings:
-Note	1305	PROCEDURE foo does not exist
+Note	1305	PROCEDURE test.foo does not exist
 show create procedure foo|
 ERROR 42000: PROCEDURE foo does not exist
 show create function foo|
@@ -1016,7 +1016,7 @@ drop table t1|
 drop function bug_13627_f|
 drop function if exists bug12329;
 Warnings:
-Note	1305	FUNCTION bug12329 does not exist
+Note	1305	FUNCTION test.bug12329 does not exist
 create table t1 as select 1 a;
 create table t2 as select 1 a;
 create function bug12329() returns int return (select a from t1);
diff -Nrup a/mysql-test/r/sp-vars.result b/mysql-test/r/sp-vars.result
--- a/mysql-test/r/sp-vars.result	2007-05-16 06:25:37 -06:00
+++ b/mysql-test/r/sp-vars.result	2008-03-12 18:01:29 -06:00
@@ -464,10 +464,10 @@ CASE expression tests.
 
 DROP PROCEDURE IF EXISTS p1;
 Warnings:
-Note	1305	PROCEDURE p1 does not exist
+Note	1305	PROCEDURE test.p1 does not exist
 DROP PROCEDURE IF EXISTS p2;
 Warnings:
-Note	1305	PROCEDURE p2 does not exist
+Note	1305	PROCEDURE test.p2 does not exist
 DROP TABLE IF EXISTS t1;
 Warnings:
 Note	1051	Unknown table 't1'
diff -Nrup a/mysql-test/r/sp.result b/mysql-test/r/sp.result
--- a/mysql-test/r/sp.result	2008-02-17 04:37:38 -07:00
+++ b/mysql-test/r/sp.result	2008-03-12 18:01:30 -06:00
@@ -2819,10 +2819,10 @@ delete from t3|
 insert into t3 values(1)|
 drop procedure if exists bug7992_1|
 Warnings:
-Note	1305	PROCEDURE bug7992_1 does not exist
+Note	1305	PROCEDURE test.bug7992_1 does not exist
 drop procedure if exists bug7992_2|
 Warnings:
-Note	1305	PROCEDURE bug7992_2 does not exist
+Note	1305	PROCEDURE test.bug7992_2 does not exist
 create procedure bug7992_1()
 begin
 declare i int;
diff -Nrup a/mysql-test/r/strict.result b/mysql-test/r/strict.result
--- a/mysql-test/r/strict.result	2008-02-06 15:33:00 -07:00
+++ b/mysql-test/r/strict.result	2008-03-12 18:01:30 -06:00
@@ -1186,7 +1186,7 @@ drop table t1;
 create table t1 (col1 tinyint);
 drop procedure if exists t1;
 Warnings:
-Note	1305	PROCEDURE t1 does not exist
+Note	1305	PROCEDURE test.t1 does not exist
 create procedure t1 () begin declare exit handler for sqlexception
 select'a'; insert into t1 values (200); end;|
 call t1();
diff -Nrup a/mysql-test/r/udf.result b/mysql-test/r/udf.result
--- a/mysql-test/r/udf.result	2007-11-27 08:16:51 -07:00
+++ b/mysql-test/r/udf.result	2008-03-12 18:01:30 -06:00
@@ -354,4 +354,50 @@ a
 4
 DROP FUNCTION sequence;
 DROP TABLE t1,t2;
+drop function if exists test.metaphon;
+drop function if exists metaphon;
+CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
+select metaphon("Hello");
+metaphon("Hello")
+HL
+drop function if exists test.metaphon;
+Warnings:
+Note	1305	FUNCTION test.metaphon does not exist
+select metaphon("Hello");
+metaphon("Hello")
+HL
+drop function metaphon;
+CREATE FUNCTION test.metaphon(a TEXT) RETURNS TEXT return "This is a SF";
+create database db_31767;
+use db_31767;
+CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
+use test;
+select metaphon("Hello");
+metaphon("Hello")
+HL
+select test.metaphon("Hello");
+test.metaphon("Hello")
+This is a SF
+drop function metaphon;
+select metaphon("Hello");
+metaphon("Hello")
+This is a SF
+drop function metaphon;
+use db_31767;
+drop database db_31767;
+drop function if exists no_such_func;
+Warnings:
+Note	1305	FUNCTION (UDF) no_such_func does not exist
+drop function no_such_func;
+ERROR 42000: FUNCTION (UDF) no_such_func does not exist
+drop function if exists test.no_such_func;
+Warnings:
+Note	1305	FUNCTION test.no_such_func does not exist
+drop function test.no_such_func;
+ERROR 42000: FUNCTION test.no_such_func does not exist
+drop procedure if exists no_such_proc;
+ERROR 3D000: No database selected
+drop procedure no_such_proc;
+ERROR 3D000: No database selected
+use test;
 End of 5.0 tests.
diff -Nrup a/mysql-test/r/view.result b/mysql-test/r/view.result
--- a/mysql-test/r/view.result	2008-02-22 01:34:17 -07:00
+++ b/mysql-test/r/view.result	2008-03-12 18:01:30 -06:00
@@ -2079,7 +2079,7 @@ CREATE TABLE t1 ( bug_table_seq   INTEGE
 CREATE OR REPLACE VIEW v1 AS SELECT * from t1;
 DROP PROCEDURE IF EXISTS p1;
 Warnings:
-Note	1305	PROCEDURE p1 does not exist
+Note	1305	PROCEDURE test.p1 does not exist
 CREATE PROCEDURE p1 ( )
 BEGIN
 DO (SELECT  @next := IFNULL(max(bug_table_seq),0) + 1 FROM v1);
diff -Nrup a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
--- a/mysql-test/r/warnings.result	2008-02-06 15:33:01 -07:00
+++ b/mysql-test/r/warnings.result	2008-03-12 18:01:30 -06:00
@@ -252,13 +252,13 @@ INSERT INTO t2 VALUES ( 'a`', 'a`' );
 INSERT INTO t3 VALUES ( 'a`', 'a`', '1000-01-1' );
 DROP PROCEDURE IF EXISTS sp1;
 Warnings:
-Note	1305	PROCEDURE sp1 does not exist
+Note	1305	PROCEDURE test.sp1 does not exist
 DROP PROCEDURE IF EXISTS sp2;
 Warnings:
-Note	1305	PROCEDURE sp2 does not exist
+Note	1305	PROCEDURE test.sp2 does not exist
 DROP PROCEDURE IF EXISTS sp3;
 Warnings:
-Note	1305	PROCEDURE sp3 does not exist
+Note	1305	PROCEDURE test.sp3 does not exist
 CREATE PROCEDURE sp1()
 BEGIN
 DECLARE x NUMERIC ZEROFILL;
diff -Nrup a/mysql-test/t/udf.test b/mysql-test/t/udf.test
--- a/mysql-test/t/udf.test	2007-11-27 08:16:51 -07:00
+++ b/mysql-test/t/udf.test	2008-03-12 18:01:30 -06:00
@@ -383,4 +383,73 @@ SELECT * FROM t2 WHERE a = sequence();
 DROP FUNCTION sequence;
 DROP TABLE t1,t2;
 
+#
+# Bug#31767 (DROP FUNCTION name resolution)
+#
+
+--disable_warnings
+drop function if exists test.metaphon;
+drop function if exists metaphon;
+--enable_warnings
+
+--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
+eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB";
+
+select metaphon("Hello");
+
+# The UDF should not be dropped
+drop function if exists test.metaphon;
+
+select metaphon("Hello");
+
+drop function metaphon;
+
+CREATE FUNCTION test.metaphon(a TEXT) RETURNS TEXT return "This is a SF";
+
+create database db_31767;
+use db_31767;
+
+--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
+eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB";
+
+use test;
+
+# Uses the UDF
+select metaphon("Hello");
+
+# Uses the SF
+select test.metaphon("Hello");
+
+# Should drop the UDF, resolving the name the same way select does.
+drop function metaphon;
+
+# Should call the SF
+select metaphon("Hello");
+
+# Drop the SF
+drop function metaphon;
+
+# Change the current database to none.
+use db_31767;
+drop database db_31767;
+
+drop function if exists no_such_func;
+
+--error ER_SP_DOES_NOT_EXIST
+drop function no_such_func;
+
+drop function if exists test.no_such_func;
+
+--error ER_SP_DOES_NOT_EXIST
+drop function test.no_such_func;
+
+--error ER_NO_DB_ERROR
+drop procedure if exists no_such_proc;
+
+--error ER_NO_DB_ERROR
+drop procedure no_such_proc;
+
+use test;
+
+
 --echo End of 5.0 tests.
diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
--- a/sql/sql_parse.cc	2008-02-29 06:49:59 -07:00
+++ b/sql/sql_parse.cc	2008-03-12 18:01:30 -06:00
@@ -4833,10 +4833,58 @@ create_sp_error:
   case SQLCOM_DROP_PROCEDURE:
   case SQLCOM_DROP_FUNCTION:
     {
+#ifdef HAVE_DLOPEN
+      if (lex->sql_command == SQLCOM_DROP_FUNCTION &&
+          ! lex->spname->m_explicit_name)
+      {
+        /* DROP FUNCTION <non qualified name> */
+        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, 0))
+            goto error;
+
+          /* Does NOT write to binlog */
+          if (!(res = mysql_drop_function(thd, &lex->spname->m_name)))
+          {
+            send_ok(thd);
+            break;
+          }
+          my_error(ER_SP_DROP_FAILED, MYF(0),
+                   "FUNCTION (UDF)", lex->spname->m_name.str);
+          goto error;
+        }
+
+        if (lex->spname->m_db.str == NULL)
+        {
+          if (lex->drop_if_exists)
+          {
+            push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+                                ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST),
+                                "FUNCTION (UDF)", lex->spname->m_name.str);
+            res= FALSE;
+            send_ok(thd);
+            break;
+          }
+          my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
+                   "FUNCTION (UDF)", lex->spname->m_name.str);
+          goto error;
+        }
+        /* Fall thought to test for a stored function */
+      }
+#endif
+
       int sp_result;
       int type= (lex->sql_command == SQLCOM_DROP_PROCEDURE ?
                  TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION);
 
+      if (lex->spname->m_db.str == NULL)
+      {
+        my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
+        goto error;
+      }
+
       sp_result= sp_routine_exists_in_table(thd, type, lex->spname);
       mysql_reset_errors(thd, 0);
       if (sp_result == SP_OK)
@@ -4866,35 +4914,6 @@ create_sp_error:
 	else
 	  sp_result= sp_drop_function(thd, lex->spname);
       }
-      else
-      {
-#ifdef HAVE_DLOPEN
-	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, 0))
-	      goto error;
-
-	    /* Does NOT write to binlog */
-	    if (!(res = mysql_drop_function(thd, &lex->spname->m_name)))
-	    {
-	      send_ok(thd);
-	      break;
-	    }
-	  }
-	}
-#endif
-	if (lex->spname->m_db.str)
-	  sp_result= SP_KEY_NOT_FOUND;
-	else
-	{
-	  my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
-	  goto error;
-	}
-      }
       res= sp_result;
       switch (sp_result) {
       case SP_OK:
@@ -4905,7 +4924,7 @@ create_sp_error:
 	{
 	  push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
 			      ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST),
-			      SP_COM_STRING(lex), lex->spname->m_name.str);
+                              SP_COM_STRING(lex), lex->spname->m_qname.str);
 	  res= FALSE;
 	  send_ok(thd);
 	  break;
Thread
bk commit into 5.0 tree (malff:1.2604) BUG#31767marc.alff13 Mar
  • Re: bk commit into 5.0 tree (malff:1.2604) BUG#31767Davi Arnaut31 Mar