MySQL 8.0.40
Source Code Documentation
sql_trigger.h File Reference

This file contains declarations of global public functions which are used directly from parser/executioner to perform basic operations on triggers (CREATE TRIGGER, DROP TRIGGER, ALTER TABLE, DROP TABLE, ...) More...

#include "lex_string.h"
#include "my_psi_config.h"
#include "my_sqlcommand.h"
#include "sql/mdl.h"
#include "sql/sql_cmd.h"

Go to the source code of this file.

Classes

class  Sql_cmd_ddl_trigger_common
 This class has common code for CREATE/DROP TRIGGER statements. More...
 
class  Sql_cmd_create_trigger
 This class implements the CREATE TRIGGER statement. More...
 
class  Sql_cmd_drop_trigger
 This class implements the DROP TRIGGER statement. More...
 

Namespaces

namespace  dd
 The version of the current data dictionary table definitions.
 

Functions

bool get_table_for_trigger (THD *thd, const LEX_CSTRING &db_name, const LEX_STRING &trigger_name, bool continue_if_not_exist, Table_ref **table)
 Find trigger's table from trigger identifier. More...
 
bool check_table_triggers_are_not_in_the_same_schema (const char *db_name, const dd::Table &table, const char *new_db_name)
 Check for table with triggers that old database name and new database name are the same. More...
 
bool acquire_mdl_for_trigger (THD *thd, const char *db, const char *trg_name, enum_mdl_type trigger_name_mdl_type)
 Acquire either exclusive or shared MDL lock for a trigger in specified schema. More...
 
bool acquire_exclusive_mdl_for_trigger (THD *thd, const char *db, const char *trg_name)
 Acquire exclusive MDL lock for a trigger in specified schema. More...
 
bool acquire_shared_mdl_for_trigger (THD *thd, const char *db, const char *trg_name)
 Acquire shared MDL lock for a trigger in specified schema. More...
 
void remove_all_triggers_from_perfschema (const char *schema_name, const dd::Table &table)
 Drop statistics from performance schema for every trigger associated with a table. More...
 

Detailed Description

This file contains declarations of global public functions which are used directly from parser/executioner to perform basic operations on triggers (CREATE TRIGGER, DROP TRIGGER, ALTER TABLE, DROP TABLE, ...)

Function Documentation

◆ acquire_exclusive_mdl_for_trigger()

bool acquire_exclusive_mdl_for_trigger ( THD thd,
const char *  db,
const char *  trg_name 
)

Acquire exclusive MDL lock for a trigger in specified schema.

Parameters
[in]thdCurrent thread context
[in]dbSchema name
[in]trg_nameTrigger name
Returns
Operation status.
Return values
falseSuccess
trueFailure

◆ acquire_mdl_for_trigger()

bool acquire_mdl_for_trigger ( THD thd,
const char *  db,
const char *  trg_name,
enum_mdl_type  trigger_name_mdl_type 
)

Acquire either exclusive or shared MDL lock for a trigger in specified schema.

Parameters
[in]thdCurrent thread context
[in]dbSchema name
[in]trg_nameTrigger name
[in]trigger_name_mdl_typeType of MDL to acquire for trigger name
Returns
Operation status.
Return values
falseSuccess
trueFailure

◆ acquire_shared_mdl_for_trigger()

bool acquire_shared_mdl_for_trigger ( THD thd,
const char *  db,
const char *  trg_name 
)
inline

Acquire shared MDL lock for a trigger in specified schema.

Parameters
[in]thdCurrent thread context
[in]dbSchema name
[in]trg_nameTrigger name
Returns
Operation status.
Return values
falseSuccess
trueFailure

◆ check_table_triggers_are_not_in_the_same_schema()

bool check_table_triggers_are_not_in_the_same_schema ( const char *  db_name,
const dd::Table table,
const char *  new_db_name 
)

Check for table with triggers that old database name and new database name are the same.

This functions is called while handling the statement RENAME TABLE to ensure that table moved within the same database.

Parameters
[in]db_nameSchema name.
[in]tableTable.
[in]new_db_nameNew schema name
Note
Set error ER_TRG_IN_WRONG_SCHEMA in Diagnostics_area in case function returns true.
Returns
Operation status
Return values
falseEither there is no triggers assigned to a table or old and new schema name are the same.
trueOld and new schema name aren't the same.

◆ get_table_for_trigger()

bool get_table_for_trigger ( THD thd,
const LEX_CSTRING db_name,
const LEX_STRING trigger_name,
bool  continue_if_not_exist,
Table_ref **  table 
)

Find trigger's table from trigger identifier.

Parameters
[in]thdThread context.
[in]db_nameSchema name.
[in]trigger_nameTrigger name.
[in]continue_if_not_existtrue if SQL statement contains "IF EXISTS" clause. That means a warning instead of error should be thrown if trigger with given name does not exist.
[out]tablePointer to Table_ref object for the table trigger.
Returns
Operation status
Return values
falseOn success.
trueOtherwise.

◆ remove_all_triggers_from_perfschema()

void remove_all_triggers_from_perfschema ( const char *  schema_name,
const dd::Table table 
)

Drop statistics from performance schema for every trigger associated with a table.

Parameters
schema_nameName of schema containing the table.
tableTable reference, for that associated triggers statistics has to be deleted.