MySQL 8.0.40
Source Code Documentation
|
This class represents a trigger object. More...
#include <trigger.h>
Public Member Functions | |
bool | execute (THD *thd) |
Execute trigger's body. More... | |
bool | parse (THD *thd, bool is_upgrade) |
Parse CREATE TRIGGER statement. More... | |
void | add_tables_and_routines (THD *thd, Query_tables_list *prelocking_ctx, Table_ref *table_list) |
Add tables and routines used by trigger to the set of elements used by statement. More... | |
void | print_upgrade_warning (THD *thd) |
Print upgrade warnings (if any). More... | |
const LEX_CSTRING & | get_db_name () const |
const LEX_CSTRING & | get_subject_table_name () const |
const LEX_CSTRING & | get_trigger_name () const |
const LEX_CSTRING & | get_definition () const |
const LEX_CSTRING & | get_definition_utf8 () const |
sql_mode_t | get_sql_mode () const |
const LEX_CSTRING & | get_definer () const |
const LEX_CSTRING & | get_definer_user () const |
const LEX_CSTRING & | get_definer_host () const |
const LEX_CSTRING & | get_client_cs_name () const |
const LEX_CSTRING & | get_connection_cl_name () const |
const LEX_CSTRING & | get_db_cl_name () const |
enum_trigger_event_type | get_event () const |
const LEX_CSTRING & | get_event_as_string () const |
enum_trigger_action_time_type | get_action_time () const |
const LEX_CSTRING & | get_action_time_as_string () const |
bool | is_created_timestamp_null () const |
my_timeval | get_created_timestamp () const |
ulonglong | get_action_order () const |
void | set_action_order (ulonglong action_order) |
sp_head * | get_sp () |
GRANT_INFO * | get_subject_table_grant () |
bool | has_parse_error () const |
const char * | get_parse_error_message () const |
bool | create_full_trigger_definition (const THD *thd, String *full_trigger_definition) const |
Construct a full CREATE TRIGGER statement from Trigger's data members. More... | |
~Trigger () | |
Destroy associated SP (if any). More... | |
Static Public Member Functions | |
static Trigger * | create_from_parser (THD *thd, TABLE *subject_table, String *binlog_create_trigger_stmt) |
Creates a new Trigger-instance with the state from the parser. More... | |
static Trigger * | create_from_dd (MEM_ROOT *mem_root, const LEX_CSTRING &trigger_name, const LEX_CSTRING &db_name, const LEX_CSTRING &subject_table_name, const LEX_CSTRING &definition, const LEX_CSTRING &definition_utf8, sql_mode_t sql_mode, const LEX_CSTRING &definer_user, const LEX_CSTRING &definer_host, const LEX_CSTRING &client_cs_name, const LEX_CSTRING &connection_cl_name, const LEX_CSTRING &db_cl_name, enum_trigger_event_type trg_event_type, enum_trigger_action_time_type trg_time_type, uint action_order, my_timeval created_timestamp) |
Creates a new Trigger-instance with the state loaded from the Data Dictionary. More... | |
static bool | construct_create_trigger_stmt_with_definer (THD *thd, String *binlog_query, const LEX_CSTRING &def_user, const LEX_CSTRING &def_host) |
Constructs CREATE TRIGGER statement taking into account a value of the DEFINER clause. More... | |
Private Member Functions | |
Trigger (const LEX_CSTRING &trigger_name, MEM_ROOT *mem_root, const LEX_CSTRING &db_name, const LEX_CSTRING &table_name, const LEX_CSTRING &definition, const LEX_CSTRING &definition_utf8, sql_mode_t sql_mode, const LEX_CSTRING &definer_user, const LEX_CSTRING &definer_host, const LEX_CSTRING &client_cs_name, const LEX_CSTRING &connection_cl_name, const LEX_CSTRING &db_cl_name, enum_trigger_event_type event_type, enum_trigger_action_time_type action_time, uint action_order, my_timeval created_timestamp) | |
Trigger constructor. More... | |
void | set_trigger_name (const LEX_CSTRING &trigger_name) |
void | set_trigger_def (const LEX_CSTRING &trigger_def) |
void | set_trigger_def_utf8 (const LEX_CSTRING &trigger_def_utf8) |
void | set_parse_error_message (const char *error_message) |
Private Attributes | |
MEM_ROOT * | m_mem_root |
Memory root to store all data of this Trigger object. More... | |
LEX_CSTRING | m_full_trigger_definition |
Full trigger definition reconstructed from a data loaded from the table mysql.trigger. More... | |
LEX_CSTRING | m_db_name |
Database name. More... | |
LEX_CSTRING | m_subject_table_name |
Table name. More... | |
LEX_CSTRING | m_definition |
Trigger definition to save in DD. More... | |
LEX_CSTRING | m_definition_utf8 |
Trigger definition in UTF8 to save in DD. More... | |
sql_mode_t | m_sql_mode |
Trigger sql-mode. More... | |
LEX_CSTRING | m_definer |
Trigger definer. More... | |
LEX_CSTRING | m_definer_user |
Trigger definer (user part). More... | |
LEX_CSTRING | m_definer_host |
Trigger definer (host part). More... | |
LEX_CSTRING | m_client_cs_name |
Character set context, used for parsing and executing trigger. More... | |
LEX_CSTRING | m_connection_cl_name |
Collation name of the connection within one a trigger are created. More... | |
LEX_CSTRING | m_db_cl_name |
Default database collation. More... | |
enum_trigger_event_type | m_event |
Trigger event. More... | |
enum_trigger_action_time_type | m_action_time |
Trigger action time. More... | |
my_timeval | m_created_timestamp |
Current time when the trigger was created (measured in milliseconds since since 0 hours, 0 minutes, 0 seconds, January 1, 1970, UTC). More... | |
ulonglong | m_action_order |
Action_order value for the trigger. More... | |
LEX_CSTRING | m_trigger_name |
Trigger name. More... | |
GRANT_INFO | m_subject_table_grant |
Grant information for the trigger. More... | |
sp_head * | m_sp |
Pointer to the sp_head corresponding to the trigger. More... | |
bool | m_has_parse_error |
This flags specifies whether the trigger has parse error or not. More... | |
char | m_parse_error_message [MYSQL_ERRMSG_SIZE] |
This error will be displayed when the user tries to manipulate or invoke triggers on a table that has broken triggers. More... | |
This class represents a trigger object.
Trigger can be created, initialized, parsed and executed.
Trigger attributes are usually stored on the memory root of the subject table. Trigger object however can exist when the subject table does not. In this case, trigger attributes are stored on a separate memory root.
Trigger objects are created in two ways:
loading from Data Dictionary (by Trigger_loader)
In this case Trigger object is initialized from the data which is directly available in data dictionary;
creating a new Trigger object that represents the trigger object being created by CREATE TRIGGER statement (by Table_trigger_dispatcher).
In this case Trigger object is created temporarily.
|
private |
Trigger constructor.
Trigger::~Trigger | ( | ) |
Destroy associated SP (if any).
void Trigger::add_tables_and_routines | ( | THD * | thd, |
Query_tables_list * | prelocking_ctx, | ||
Table_ref * | table_list | ||
) |
Add tables and routines used by trigger to the set of elements used by statement.
[in] | thd | thread handle |
[in,out] | prelocking_ctx | prelocking context of the statement |
[in] | table_list | Table_ref for the table |
|
static |
Constructs CREATE TRIGGER statement taking into account a value of the DEFINER clause.
The point of this method is to create canonical forms of CREATE TRIGGER statement for writing into the binlog.
thd | thread context | |
[out] | binlog_query | well-formed CREATE TRIGGER statement for putting into binlog (after successful execution) |
def_user | user part of a definer value | |
def_host | host part of a definer value |
false | Success |
true | Failure |
|
static |
Creates a new Trigger-instance with the state loaded from the Data Dictionary.
[in] | mem_root | MEM_ROOT for memory allocation. |
[in] | trigger_name | name of trigger |
[in] | db_name | name of schema. |
[in] | subject_table_name | subject table name. |
[in] | definition | CREATE TRIGGER statement. |
[in] | definition_utf8 | CREATE TRIGGER statement in UTF8. |
[in] | sql_mode | sql_mode value. |
[in] | definer_user | user part of a 'definer' value. |
[in] | definer_host | host part of a 'definer' value. |
[in] | client_cs_name | client character set name. |
[in] | connection_cl_name | connection collation name. |
[in] | db_cl_name | database collation name. |
[in] | trg_event_type | trigger event type |
[in] | trg_time_type | trigger action timing |
[in] | action_order | action order |
[in] | created_timestamp | trigger creation time stamp. |
|
static |
Creates a new Trigger-instance with the state from the parser.
This method is used to create a Trigger-object after CREATE TRIGGER statement is parsed.
thd | Thread context with a valid LEX-tree of CREATE TRIGGER statement | |
subject_table | A valid (not fake!) subject TABLE-object | |
[out] | binlog_create_trigger_stmt | Store CREATE TRIGGER appropriate to writing into the binlog. It should have DEFINER clause and should not have FOLLOWS/PRECEDES clause. |
bool Trigger::create_full_trigger_definition | ( | const THD * | thd, |
String * | full_trigger_definition | ||
) | const |
Construct a full CREATE TRIGGER statement from Trigger's data members.
[in] | thd | Thread context |
[out] | full_trigger_definition | Place where a CREATE TRIGGER statement be stored. |
true | Failure |
false | Success |
bool Trigger::execute | ( | THD * | thd | ) |
Execute trigger's body.
[in] | thd | Thread context |
true | Trigger execution failed or trigger has compilation errors |
false | Success |
|
inline |
|
inline |
const LEX_CSTRING & Trigger::get_action_time_as_string | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
const LEX_CSTRING & Trigger::get_event_as_string | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool Trigger::parse | ( | THD * | thd, |
bool | is_upgrade | ||
) |
Parse CREATE TRIGGER statement.
[in] | thd | Thread context |
[in] | is_upgrade | Flag to indicate that trigger being parsed is read from .TRG file in case of upgrade. |
void Trigger::print_upgrade_warning | ( | THD * | thd | ) |
Print upgrade warnings (if any).
[in] | thd | Thread handle. |
|
inline |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
private |
Action_order value for the trigger.
Action_order is the ordinal position of the trigger in the list of triggers with the same EVENT_MANIPULATION, CONDITION_TIMING, and ACTION_ORIENTATION.
|
private |
Trigger action time.
|
private |
Character set context, used for parsing and executing trigger.
|
private |
Collation name of the connection within one a trigger are created.
|
private |
Current time when the trigger was created (measured in milliseconds since since 0 hours, 0 minutes, 0 seconds, January 1, 1970, UTC).
This is the value of CREATED attribute.
There is special value – zero means CREATED is not set (NULL).
|
private |
Default database collation.
|
private |
Database name.
|
private |
Trigger definer.
|
private |
Trigger definer (host part).
|
private |
Trigger definer (user part).
|
private |
Trigger definition to save in DD.
|
private |
Trigger definition in UTF8 to save in DD.
|
private |
Trigger event.
|
private |
Full trigger definition reconstructed from a data loaded from the table mysql.trigger.
|
private |
This flags specifies whether the trigger has parse error or not.
|
private |
Memory root to store all data of this Trigger object.
This can be a pointer to the subject table memory root, or it can be a pointer to a dedicated memory root if subject table does not exist.
|
private |
This error will be displayed when the user tries to manipulate or invoke triggers on a table that has broken triggers.
It will get set only once per statement and thus will contain the first parse error encountered in the trigger file.
|
private |
Pointer to the sp_head corresponding to the trigger.
|
private |
Trigger sql-mode.
|
private |
Grant information for the trigger.
|
private |
Table name.
|
private |
Trigger name.