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

Function drop_routine

sql/sql_parse.cc:6479–6597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6477
6478
6479static bool __attribute__ ((noinline))
6480drop_routine(THD *thd, LEX *lex)
6481{
6482 int sp_result;
6483#ifdef HAVE_DLOPEN
6484 if (lex->sql_command == SQLCOM_DROP_FUNCTION &&
6485 ! lex->spname->m_explicit_name)
6486 {
6487 /* DROP FUNCTION <non qualified name> */
6488 enum drop_udf_result rc= mysql_drop_function(thd, &lex->spname->m_name);
6489 switch (rc) {
6490 case UDF_DEL_RESULT_DELETED:
6491 my_ok(thd);
6492 return 0;
6493 case UDF_DEL_RESULT_ERROR:
6494 return 1;
6495 case UDF_DEL_RESULT_ABSENT:
6496 goto absent;
6497 }
6498
6499 DBUG_ASSERT("wrong return code" == 0);
6500absent:
6501 // If there was no current database, so it cannot be SP
6502 if (!lex->spname->m_db.str)
6503 {
6504 if (lex->if_exists())
6505 {
6506 push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
6507 ER_SP_DOES_NOT_EXIST,
6508 ER_THD(thd, ER_SP_DOES_NOT_EXIST),
6509 "FUNCTION (UDF)", lex->spname->m_name.str);
6510 my_ok(thd);
6511 return 0;
6512 }
6513 my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
6514 "FUNCTION (UDF)", lex->spname->m_name.str);
6515 return 1;
6516 }
6517 /* Fall trough to test for a stored function */
6518 }
6519#endif /* HAVE_DLOPEN */
6520
6521 const Sp_handler *sph= Sp_handler::handler(lex->sql_command);
6522
6523 if (check_routine_access(thd, ALTER_PROC_ACL, &lex->spname->m_db,
6524 &lex->spname->m_name,
6525 Sp_handler::handler(lex->sql_command), 0))
6526 return 1;
6527
6528 WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
6529
6530 /* Conditionally writes to binlog */
6531 sp_result= sph->sp_drop_routine(thd, lex->spname);
6532
6533#ifndef NO_EMBEDDED_ACCESS_CHECKS
6534 /*
6535 We're going to issue an implicit REVOKE statement so we close all
6536 open tables. We have to keep metadata locks as this ensures that

Callers 1

sql_parse.ccFile · 0.85

Calls 15

mysql_drop_functionFunction · 0.85
my_okFunction · 0.85
push_warning_printfFunction · 0.85
my_errorFunction · 0.85
trans_commit_stmtFunction · 0.85
close_thread_tablesFunction · 0.85
sp_revoke_privilegesFunction · 0.85
Lex_ident_routineClass · 0.85
push_warningFunction · 0.85
write_bin_logFunction · 0.85
ErrConvDQNameClass · 0.85
sp_drop_routineMethod · 0.80

Tested by

no test coverage detected