![]() |
MySQL 9.3.0
Source Code Documentation
|
This class holds all information about triggers of a table. More...
#include <table_trigger_dispatcher.h>
Public Member Functions | |
bool | finalize_load (THD *thd) |
Finalize load of triggers for the table by creating Trigger objects to be associated with TABLE/Table_trigger_dispatcher (rather than with TABLE_SHARE), parsing trigger bodies, creating trigger chains, preparing sp_head objects and row accessors. More... | |
~Table_trigger_dispatcher () override | |
bool | check_for_broken_triggers () |
Checks if there is a broken trigger for this table. More... | |
bool | create_trigger (THD *thd, String *binlog_create_trigger_stmt, bool if_not_exists, bool &already_exists) |
Create trigger for table. More... | |
bool | process_triggers (THD *thd, enum_trigger_event_type event, enum_trigger_action_time_type action_time, bool old_row_is_record1) |
Execute trigger for given (event, time) pair. More... | |
Trigger_chain * | get_triggers (int event, int action_time) |
const Trigger_chain * | get_triggers (int event, int action_time) const |
Trigger * | find_trigger (const LEX_STRING &trigger_name) |
Get trigger object by trigger name. More... | |
bool | has_triggers (enum_trigger_event_type event, enum_trigger_action_time_type action_time) const |
bool | has_update_triggers () const |
bool | has_delete_triggers () const |
bool | mark_fields (enum_trigger_event_type event) |
Mark fields of subject table which we read/set in its triggers as such. More... | |
bool | add_tables_and_routines_for_triggers (THD *thd, Query_tables_list *prelocking_ctx, Table_ref *table_list) |
Add triggers for table to the set of routines used by statement. More... | |
void | enable_fields_temporary_nullability (THD *thd) |
Mark all trigger fields as "temporary nullable" and remember the current THD::check_for_truncated_fields value. More... | |
void | disable_fields_temporary_nullability () |
Reset "temporary nullable" flag from trigger fields. More... | |
void | reset_field_nulls () |
Reset the temporary null values set to the field for triggers. More... | |
void | print_upgrade_warnings (THD *thd) |
Iterate along triggers and print necessary upgrade warnings. More... | |
void | parse_triggers (THD *thd, List< Trigger > *triggers, bool is_upgrade) |
Parse trigger definition statements (CREATE TRIGGER). More... | |
bool | has_load_been_finalized () |
Check whether we have finalized loading of triggers for the table by parsing their bodies, creating sp_head objects and preparing row-accessors. More... | |
![]() | |
virtual | ~Table_trigger_field_support ()=default |
Static Public Member Functions | |
static Table_trigger_dispatcher * | create (TABLE *subject_table) |
Create an instance of Table_trigger_dispatcher for the given subject table. More... | |
Private Member Functions | |
Table_trigger_dispatcher (TABLE *subject_table) | |
Private form of Table_trigger_dispatcher constructor. More... | |
Trigger_chain * | create_trigger_chain (MEM_ROOT *mem_root, enum_trigger_event_type event, enum_trigger_action_time_type action_time) |
Make sure there is a chain for the specified event and action time. More... | |
bool | prepare_record1_accessors () |
Prepare array of Field objects referencing to TABLE::record[1] instead of record<a href="they will represent OLD. More... | |
void | set_parse_error_message (const char *error_message) |
Remember a parse error that occurred while parsing trigger definitions loaded from the Data Dictionary. More... | |
TABLE * | get_subject_table () override |
Field * | get_trigger_variable_field (enum_trigger_variable_type v, int field_index) override |
Private Attributes | |
TABLE * | m_subject_table |
TABLE instance for which this triggers list object was created. More... | |
Trigger_chain * | m_trigger_map [TRG_EVENT_MAX][TRG_ACTION_MAX] |
Triggers grouped by event, action_time. More... | |
Field ** | m_record1_field |
Copy of TABLE::Field array with field pointers set to TABLE::record[1] buffer instead of TABLE::record[0] (used for OLD values in on UPDATE trigger and DELETE trigger when it is called for REPLACE). More... | |
Field ** | m_new_field |
During execution of trigger m_new_field and m_old_field should point to the array of fields representing new or old version of row correspondingly (so it can point to TABLE::field or to Table_trigger_dispatcher::m_record1_field). More... | |
Field ** | m_old_field |
const char * | m_parse_error_message |
Error which occurred while parsing one of the triggers for the table; nullptr if there was no error for any of its triggers. More... | |
bool | m_load_finalized |
Indicates whether we have finalized loading of triggers for the table. More... | |
Friends | |
class | table_cache_unittest::Mock_share |
This class holds all information about triggers of a table.
|
private |
Private form of Table_trigger_dispatcher constructor.
In order to construct an instance of Table_trigger_dispatcher with a valid pointer to the subject table, use Table_trigger_dispatcher::create().
|
override |
bool Table_trigger_dispatcher::add_tables_and_routines_for_triggers | ( | THD * | thd, |
Query_tables_list * | prelocking_ctx, | ||
Table_ref * | table_list | ||
) |
Add triggers for table to the set of routines used by statement.
Add tables used by them to statement table list. Do the same for routines used by triggers.
thd | Thread context. |
prelocking_ctx | Prelocking context of the statement. |
table_list | Table list element for table with trigger. |
false | Success |
true | Failure |
|
inline |
Checks if there is a broken trigger for this table.
false | if all triggers are Ok. |
true | in case there is at least one broken trigger (a trigger which SQL-definition can not be parsed) for this table. |
|
static |
Create an instance of Table_trigger_dispatcher for the given subject table.
subject_table | valid (not fake!) TABLE-object representing the subject table |
bool Table_trigger_dispatcher::create_trigger | ( | THD * | thd, |
String * | binlog_create_trigger_stmt, | ||
bool | if_not_exists, | ||
bool & | already_exists | ||
) |
Create trigger for table.
thd | Thread context | |
[out] | binlog_create_trigger_stmt | Well-formed CREATE TRIGGER statement for putting into binlog (after successful execution) |
if_not_exists | True if 'IF NOT EXISTS' clause was specified | |
[out] | already_exists | Set to true if trigger already exists on the same table |
false | Success |
true | Failure |
|
private |
Make sure there is a chain for the specified event and action time.
void Table_trigger_dispatcher::disable_fields_temporary_nullability | ( | ) |
Reset "temporary nullable" flag from trigger fields.
void Table_trigger_dispatcher::enable_fields_temporary_nullability | ( | THD * | thd | ) |
Mark all trigger fields as "temporary nullable" and remember the current THD::check_for_truncated_fields value.
thd | Thread context. |
bool Table_trigger_dispatcher::finalize_load | ( | THD * | thd | ) |
Finalize load of triggers for the table by creating Trigger objects to be associated with TABLE/Table_trigger_dispatcher (rather than with TABLE_SHARE), parsing trigger bodies, creating trigger chains, preparing sp_head objects and row accessors.
thd | current thread context |
false | Success |
true | Failure |
Trigger * Table_trigger_dispatcher::find_trigger | ( | const LEX_STRING & | trigger_name | ) |
Get trigger object by trigger name.
[in] | trigger_name | trigger name |
|
inlineoverrideprivatevirtual |
Implements Table_trigger_field_support.
|
inlineoverrideprivatevirtual |
Implements Table_trigger_field_support.
|
inline |
|
inline |
|
inline |
|
inline |
Check whether we have finalized loading of triggers for the table by parsing their bodies, creating sp_head objects and preparing row-accessors.
|
inline |
|
inline |
bool Table_trigger_dispatcher::mark_fields | ( | enum_trigger_event_type | event | ) |
Mark fields of subject table which we read/set in its triggers as such.
This method marks fields of subject table which are read/set in its triggers as such (by properly updating TABLE::read_set/write_set) and thus informs handler that values for these fields should be retrieved/stored during execution of statement.
event | Type of event triggers for which we are going to inspect |
void Table_trigger_dispatcher::parse_triggers | ( | THD * | thd, |
List< Trigger > * | triggers, | ||
bool | is_upgrade | ||
) |
Parse trigger definition statements (CREATE TRIGGER).
[in] | thd | Thread context |
[in] | is_upgrade | Flag to indicate that trigger being parsed is read from .TRG file in case of upgrade. |
[in] | triggers | List of triggers to parse |
|
private |
Prepare array of Field objects referencing to TABLE::record[1] instead of record<a href="they will represent OLD.
false | Success |
true | Failure |
void Table_trigger_dispatcher::print_upgrade_warnings | ( | THD * | thd | ) |
Iterate along triggers and print necessary upgrade warnings.
Now it prints the warning about missing 'CREATED' attribute.
thd | Thread context. |
bool Table_trigger_dispatcher::process_triggers | ( | THD * | thd, |
enum_trigger_event_type | event, | ||
enum_trigger_action_time_type | action_time, | ||
bool | old_row_is_record1 | ||
) |
Execute trigger for given (event, time) pair.
The operation executes trigger for the specified event (insert, update, delete) and time (after, before) if it is set.
thd | Thread handle |
event | Insert, update or delete |
action_time | Before or after |
old_row_is_record1 | If record1 contains old or new field. |
false | Success |
true | Failure |
void Table_trigger_dispatcher::reset_field_nulls | ( | ) |
Reset the temporary null values set to the field for triggers.
|
private |
Remember a parse error that occurred while parsing trigger definitions loaded from the Data Dictionary.
This makes the Table_trigger_dispatcher enter the error state flagged by m_parse_error_message != nullptr . The error message will be used whenever a statement invoking or manipulating triggers is issued against the Table_trigger_dispatcher's table.
error_message | The error message thrown by the parser. |
|
friend |
|
private |
Indicates whether we have finalized loading of triggers for the table.
|
private |
During execution of trigger m_new_field and m_old_field should point to the array of fields representing new or old version of row correspondingly (so it can point to TABLE::field or to Table_trigger_dispatcher::m_record1_field).
|
private |
|
private |
Error which occurred while parsing one of the triggers for the table; nullptr if there was no error for any of its triggers.
Non-nullptr value indicates that as a precaution the object has entered the state where all trigger operations result in errors (referencing this error message saved) until all the table triggers are dropped. It is not safe to add triggers since it is unknown if the broken trigger has the same name or event type. Nor is it safe to invoke any trigger. The only safe operations are drop_trigger() and drop_all_triggers().
|
private |
Copy of TABLE::Field array with field pointers set to TABLE::record[1] buffer instead of TABLE::record[0] (used for OLD values in on UPDATE trigger and DELETE trigger when it is called for REPLACE).
|
private |
TABLE instance for which this triggers list object was created.
|
private |
Triggers grouped by event, action_time.