MCPcopy Create free account
hub / github.com/MariaDB/server / mysql_drop_function

Function mysql_drop_function

sql/sql_udf.cc:659–740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657
658
659enum drop_udf_result mysql_drop_function(THD *thd, const LEX_CSTRING *udf_name)
660{
661 TABLE *table;
662 udf_func *udf;
663 DBUG_ENTER("mysql_drop_function");
664
665 if (thd->locked_tables_mode)
666 {
667 my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
668 DBUG_RETURN(UDF_DEL_RESULT_ERROR);
669 }
670
671 if (!(table= open_udf_func_table(thd)))
672 DBUG_RETURN(UDF_DEL_RESULT_ERROR);
673
674 // Fast pre-check
675 if (!mysql_rwlock_tryrdlock(&THR_LOCK_udf))
676 {
677 bool found= find_udf_everywhere(thd, *udf_name, table);
678 mysql_rwlock_unlock(&THR_LOCK_udf);
679 if (!found)
680 {
681 close_mysql_tables(thd);
682 DBUG_RETURN(UDF_DEL_RESULT_ABSENT);
683 }
684 }
685
686 if (!initialized)
687 {
688 close_mysql_tables(thd);
689 if (opt_noacl)
690 DBUG_RETURN(UDF_DEL_RESULT_ABSENT); // SP should be checked
691
692 my_message(ER_OUT_OF_RESOURCES, ER_THD(thd, ER_OUT_OF_RESOURCES), MYF(0));
693 DBUG_RETURN(UDF_DEL_RESULT_ERROR);
694 }
695
696 mysql_rwlock_wrlock(&THR_LOCK_udf);
697
698 // re-check under protection
699 if (!find_udf_everywhere(thd, *udf_name, table))
700 {
701 close_mysql_tables(thd);
702 mysql_rwlock_unlock(&THR_LOCK_udf);
703 DBUG_RETURN(UDF_DEL_RESULT_ABSENT);
704 }
705
706 if (check_access(thd, DELETE_ACL, "mysql", NULL, NULL, 1, 0))
707 goto err;
708
709
710 DEBUG_SYNC(current_thd, "mysql_drop_function_after_lock");
711
712 if (!(udf= (udf_func*) my_hash_search(&udf_hash, (uchar*) udf_name->str,
713 (uint) udf_name->length)) )
714 {
715 if (remove_udf_in_table(*udf_name, table))
716 goto err;

Callers 1

drop_routineFunction · 0.85

Calls 12

my_errorFunction · 0.85
open_udf_func_tableFunction · 0.85
find_udf_everywhereFunction · 0.85
close_mysql_tablesFunction · 0.85
my_messageFunction · 0.85
my_hash_searchFunction · 0.85
remove_udf_in_tableFunction · 0.85
write_bin_logFunction · 0.85
query_lengthMethod · 0.80
check_accessFunction · 0.70
queryMethod · 0.45

Tested by

no test coverage detected