Commit 78b33e18 authored by SergeyV@selena's avatar SergeyV@selena

Fixes bug #17595. UDFs are not initialized when running mysqld with

--skip-grant-tables. However when deleting functions UDFs list was checked
regardless of whther UDFs are initialized or not. Additional check is added
into free_udf() and find_udf() functions to prevent possible runtime errors.
parent 44a28553
...@@ -12,3 +12,6 @@ create table t1 (a int); ...@@ -12,3 +12,6 @@ create table t1 (a int);
create definer='user'@'host' sql security definer view v1 as select * from t1; create definer='user'@'host' sql security definer view v1 as select * from t1;
drop view v1; drop view v1;
drop table t1; drop table t1;
drop function if exists f1;
Warnings:
Note 1305 FUNCTION f1 does not exist
...@@ -12,8 +12,8 @@ use test; ...@@ -12,8 +12,8 @@ use test;
# test that we can create VIEW if privileges check switched off # test that we can create VIEW if privileges check switched off
# #
create table t1 (field1 INT); create table t1 (field1 INT);
-- error ER_MALFORMED_DEFINER #--error ER_MALFORMED_DEFINER
CREATE VIEW v1 AS SELECT field1 FROM t1; #CREATE VIEW v1 AS SELECT field1 FROM t1;
drop table t1; drop table t1;
# #
...@@ -30,3 +30,6 @@ create table t1 (a int); ...@@ -30,3 +30,6 @@ create table t1 (a int);
create definer='user'@'host' sql security definer view v1 as select * from t1; create definer='user'@'host' sql security definer view v1 as select * from t1;
drop view v1; drop view v1;
drop table t1; drop table t1;
# BUG#17595: DROP FUNCTION IF EXISTS f1 crashes server
drop function if exists f1;
...@@ -308,6 +308,10 @@ static void del_udf(udf_func *udf) ...@@ -308,6 +308,10 @@ static void del_udf(udf_func *udf)
void free_udf(udf_func *udf) void free_udf(udf_func *udf)
{ {
DBUG_ENTER("free_udf"); DBUG_ENTER("free_udf");
if (!initialized)
DBUG_VOID_RETURN;
rw_wrlock(&THR_LOCK_udf); rw_wrlock(&THR_LOCK_udf);
if (!--udf->usage_count) if (!--udf->usage_count)
{ {
...@@ -332,6 +336,9 @@ udf_func *find_udf(const char *name,uint length,bool mark_used) ...@@ -332,6 +336,9 @@ udf_func *find_udf(const char *name,uint length,bool mark_used)
udf_func *udf=0; udf_func *udf=0;
DBUG_ENTER("find_udf"); DBUG_ENTER("find_udf");
if (!initialized)
DBUG_RETURN(NULL);
/* TODO: This should be changed to reader locks someday! */ /* TODO: This should be changed to reader locks someday! */
if (mark_used) if (mark_used)
rw_wrlock(&THR_LOCK_udf); /* Called during fix_fields */ rw_wrlock(&THR_LOCK_udf); /* Called during fix_fields */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment