summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/errors.result4
-rw-r--r--mysql-test/r/grant.result2
-rw-r--r--mysql-test/r/signal.result2
-rw-r--r--mysql-test/r/sp-error.result4
-rw-r--r--mysql-test/r/sp-vars.result4
-rw-r--r--mysql-test/r/sp.result4
-rw-r--r--mysql-test/r/sp_notembedded.result4
-rw-r--r--mysql-test/r/strict.result2
-rw-r--r--mysql-test/r/udf.result46
-rw-r--r--mysql-test/r/view.result2
-rw-r--r--mysql-test/r/warnings.result6
-rw-r--r--mysql-test/suite/sys_vars/r/max_prepared_stmt_count_func.result2
-rw-r--r--mysql-test/t/udf.test69
-rw-r--r--sql/sql_parse.cc71
14 files changed, 175 insertions, 47 deletions
diff --git a/mysql-test/r/errors.result b/mysql-test/r/errors.result
index 79474b960f5..a3a8fe0b147 100644
--- a/mysql-test/r/errors.result
+++ b/mysql-test/r/errors.result
@@ -61,10 +61,10 @@ create table t1 (a int unique);
create table t2 (a int);
drop function if exists f1;
Warnings:
-Note 1305 FUNCTION f1 does not exist
+Note 1305 FUNCTION test.f1 does not exist
drop function if exists f2;
Warnings:
-Note 1305 FUNCTION f2 does not exist
+Note 1305 FUNCTION test.f2 does not exist
create function f1() returns int
begin
insert into t1 (a) values (1);
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 542a056c68c..b182ee5656c 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -1231,7 +1231,7 @@ Warnings:
Note 1051 Unknown table 'test'
drop function if exists test_function;
Warnings:
-Note 1305 FUNCTION test_function does not exist
+Note 1305 FUNCTION test.test_function does not exist
drop view if exists v1;
Warnings:
Note 1051 Unknown table 'test.v1'
diff --git a/mysql-test/r/signal.result b/mysql-test/r/signal.result
index 7fb09b87778..410abffcdf0 100644
--- a/mysql-test/r/signal.result
+++ b/mysql-test/r/signal.result
@@ -2181,7 +2181,7 @@ drop procedure peter_p1 $$
drop procedure peter_p2 $$
drop procedure if exists peter_p3 $$
Warnings:
-Note 1305 PROCEDURE peter_p3 does not exist
+Note 1305 PROCEDURE test.peter_p3 does not exist
create procedure peter_p3()
begin
declare continue handler for sqlexception
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 4cefee95903..0f658ee831e 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -46,7 +46,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|
@@ -1028,7 +1028,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 --git a/mysql-test/r/sp-vars.result b/mysql-test/r/sp-vars.result
index f167986e82c..6f5b6dfb224 100644
--- a/mysql-test/r/sp-vars.result
+++ b/mysql-test/r/sp-vars.result
@@ -394,10 +394,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 --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index b656680326b..cd7874be414 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -2695,10 +2695,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 --git a/mysql-test/r/sp_notembedded.result b/mysql-test/r/sp_notembedded.result
index 228fe008447..931e66dba73 100644
--- a/mysql-test/r/sp_notembedded.result
+++ b/mysql-test/r/sp_notembedded.result
@@ -21,11 +21,11 @@ end|
call bug4902_2()|
show warnings|
Level Code Message
-Note 1305 PROCEDURE bug4902_2 does not exist
+Note 1305 PROCEDURE test.bug4902_2 does not exist
call bug4902_2()|
show warnings|
Level Code Message
-Note 1305 PROCEDURE bug4902_2 does not exist
+Note 1305 PROCEDURE test.bug4902_2 does not exist
drop procedure bug4902_2|
drop table if exists t1|
create table t1 (
diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result
index fa4096cb424..a835f021d3a 100644
--- a/mysql-test/r/strict.result
+++ b/mysql-test/r/strict.result
@@ -1183,7 +1183,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 --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result
index fbf87b2e4cc..4ddf427df8c 100644
--- a/mysql-test/r/udf.result
+++ b/mysql-test/r/udf.result
@@ -392,6 +392,52 @@ 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;
#
# Bug#46259: 5.0.83 -> 5.1.36, query doesn't work
#
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index e678718d3d5..0e79446ba81 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -2086,7 +2086,7 @@ CREATE TABLE t1 ( bug_table_seq INTEGER NOT NULL);
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 --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index 8e70ea8b53d..70b54ffceaf 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -228,13 +228,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 --git a/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_func.result b/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_func.result
index 562ef63f811..d71bdc0984f 100644
--- a/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_func.result
+++ b/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_func.result
@@ -66,7 +66,7 @@ SET GLOBAL max_prepared_stmt_count=3;
** Creating procedure **
DROP PROCEDURE IF EXISTS sp_checkstmts;
Warnings:
-Note 1305 PROCEDURE sp_checkstmts does not exist
+Note 1305 PROCEDURE test.sp_checkstmts does not exist
CREATE PROCEDURE sp_checkstmts ()
BEGIN
PREPARE newstmt from "SELECT * FROM information_schema.CHARACTER_SETS C";
diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test
index 7e383ce69fa..9bf872fa466 100644
--- a/mysql-test/t/udf.test
+++ b/mysql-test/t/udf.test
@@ -436,6 +436,75 @@ 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 #
--echo # Bug#46259: 5.0.83 -> 5.1.36, query doesn't work
--echo #
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index c7e1be2237b..714e3af5296 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4132,6 +4132,47 @@ 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", NULL, NULL, 1, 0))
+ goto error;
+
+ if (!(res = mysql_drop_function(thd, &lex->spname->m_name)))
+ {
+ my_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;
+ my_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);
@@ -4178,34 +4219,6 @@ create_sp_error:
}
#endif
}
- 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", NULL, NULL, 1, 0))
- goto error;
-
- if (!(res = mysql_drop_function(thd, &lex->spname->m_name)))
- {
- my_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:
@@ -4217,7 +4230,7 @@ create_sp_error:
res= write_bin_log(thd, TRUE, thd->query(), thd->query_length());
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);
if (!res)
my_ok(thd);
break;