MySQL 8.4.3
Source Code Documentation
|
#include "sql/sql_trigger.h"
#include <stddef.h>
#include <string.h>
#include <string>
#include <utility>
#include "m_string.h"
#include "my_base.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_psi_config.h"
#include "my_sys.h"
#include "mysql/psi/mysql_sp.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_common.h"
#include "sql/auth/sql_security_ctx.h"
#include "sql/binlog.h"
#include "sql/dd/cache/dictionary_client.h"
#include "sql/dd/dd_schema.h"
#include "sql/dd/string_type.h"
#include "sql/dd/types/abstract_table.h"
#include "sql/dd/types/table.h"
#include "sql/dd/types/trigger.h"
#include "sql/debug_sync.h"
#include "sql/derror.h"
#include "sql/mysqld.h"
#include "sql/sp_cache.h"
#include "sql/sp_head.h"
#include "sql/sql_backup_lock.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_db.h"
#include "sql/sql_error.h"
#include "sql/sql_handler.h"
#include "sql/sql_lex.h"
#include "sql/sql_table.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/table_trigger_dispatcher.h"
#include "sql/transaction.h"
#include "sql_string.h"
#include "string_with_len.h"
#include "thr_lock.h"
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... | |
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... | |
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_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_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... | |
static bool | finalize_trigger_ddl (THD *thd, const char *db_name, TABLE *table, const String &stmt_query, bool binlog_stmt, bool trg_created_or_dropped) |
Close all open instances of a trigger's table, reopen it if needed, invalidate SP-cache and possibly write a statement to binlog. 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.
[in] | thd | Current thread context |
[in] | db | Schema name |
[in] | trg_name | Trigger name |
false | Success |
true | Failure |
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.
[in] | thd | Current thread context |
[in] | db | Schema name |
[in] | trg_name | Trigger name |
[in] | trigger_name_mdl_type | Type of MDL to acquire for trigger name |
false | Success |
true | Failure |
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.
[in] | db_name | Schema name. |
[in] | table | Table. |
[in] | new_db_name | New schema name |
false | Either there is no triggers assigned to a table or old and new schema name are the same. |
true | Old and new schema name aren't the same. |
|
static |
Close all open instances of a trigger's table, reopen it if needed, invalidate SP-cache and possibly write a statement to binlog.
[in] | thd | Current thread context |
[in] | db_name | Database name where trigger's table defined |
[in] | table | Table associated with a trigger |
[in] | stmt_query | Query string to write to binlog |
[in] | binlog_stmt | Should the statement be binlogged? |
[in] | trg_created_or_dropped | Set to true if trigger is created or dropped. Set to false if the statement failed or the trigger already existed in case of CREATE TRIGGER IF NOT EXISTS. |
false | Success |
true | Failure |
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.
[in] | thd | Thread context. |
[in] | db_name | Schema name. |
[in] | trigger_name | Trigger name. |
[in] | continue_if_not_exist | true 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] | table | Pointer to Table_ref object for the table trigger. |
false | On success. |
true | Otherwise. |
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.
schema_name | Name of schema containing the table. |
table | Table reference, for that associated triggers statistics has to be deleted. |