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

Function show_create_trigger

sql/sql_show.cc:11437–11506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11435*/
11436
11437bool show_create_trigger(THD *thd, const sp_name *trg_name)
11438{
11439 TABLE_LIST *lst= get_trigger_table(thd, trg_name);
11440 uint num_tables; /* NOTE: unused, only to pass to open_tables(). */
11441 Table_triggers_list *triggers;
11442 Trigger *trigger;
11443 bool error= TRUE;
11444
11445 if (!lst)
11446 return TRUE;
11447
11448 if (check_table_access(thd, TRIGGER_ACL, lst, FALSE, 1, TRUE))
11449 {
11450 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "TRIGGER");
11451 return TRUE;
11452 }
11453
11454 /*
11455 Metadata locks taken during SHOW CREATE TRIGGER should be released when
11456 the statement completes as it is an information statement.
11457 */
11458 MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
11459
11460 /*
11461 Open the table by name in order to load Table_triggers_list object.
11462 */
11463 if (open_tables(thd, &lst, &num_tables,
11464 MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL))
11465 {
11466 my_error(ER_TRG_CANT_OPEN_TABLE, MYF(0),
11467 (const char *) trg_name->m_db.str,
11468 (const char *) lst->table_name.str);
11469
11470 goto exit;
11471
11472 /* Perform closing actions and return error status. */
11473 }
11474
11475 triggers= lst->table->triggers;
11476
11477 if (!triggers)
11478 {
11479 my_error(ER_TRG_DOES_NOT_EXIST, MYF(0));
11480 goto exit;
11481 }
11482
11483 trigger= triggers->find_trigger(&trg_name->m_name, 0);
11484
11485 if (!trigger)
11486 {
11487 my_error(ER_TRG_CORRUPTED_FILE, MYF(0),
11488 (const char *) trg_name->m_db.str,
11489 (const char *) lst->table_name.str);
11490 goto exit;
11491 }
11492
11493 error= show_create_trigger_impl(thd, trigger);
11494

Callers 1

sql_parse.ccFile · 0.85

Calls 9

get_trigger_tableFunction · 0.85
my_errorFunction · 0.85
show_create_trigger_implFunction · 0.85
close_thread_tablesFunction · 0.85
mdl_savepointMethod · 0.80
find_triggerMethod · 0.80
check_table_accessFunction · 0.70
open_tablesFunction · 0.70
rollback_to_savepointMethod · 0.45

Tested by

no test coverage detected