This class holds all information about triggers of a table.
More...
#include <table_trigger_dispatcher.h>
|
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 | 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 |
|
This class holds all information about triggers of a table.
◆ Table_trigger_dispatcher()
Table_trigger_dispatcher::Table_trigger_dispatcher |
( |
TABLE * |
subject_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().
◆ ~Table_trigger_dispatcher()
Table_trigger_dispatcher::~Table_trigger_dispatcher |
( |
| ) |
|
|
override |
◆ add_tables_and_routines_for_triggers()
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.
- Parameters
-
thd | Thread context. |
prelocking_ctx | Prelocking context of the statement. |
table_list | Table list element for table with trigger. |
- Returns
- Operation status.
- Return values
-
◆ check_for_broken_triggers()
bool Table_trigger_dispatcher::check_for_broken_triggers |
( |
| ) |
|
|
inline |
Checks if there is a broken trigger for this table.
- Return values
-
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. |
◆ create()
Create an instance of Table_trigger_dispatcher for the given subject table.
- Parameters
-
subject_table | valid (not fake!) TABLE-object representing the subject table |
- Returns
- a pointer to a new Table_trigger_dispatcher instance.
◆ create_trigger()
bool Table_trigger_dispatcher::create_trigger |
( |
THD * |
thd, |
|
|
String * |
binlog_create_trigger_stmt, |
|
|
bool |
if_not_exists, |
|
|
bool & |
already_exists |
|
) |
| |
Create trigger for table.
- Parameters
-
| 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 |
- Note
- Assumes that trigger name is fully qualified.
- NULL-string means the following LEX_STRING instance: { str = 0; length = 0 }.
- In other words, definer_user and definer_host should contain simultaneously NULL-strings (non-SUID/old trigger) or valid strings (SUID/new trigger).
- Returns
- Operation status.
- Return values
-
◆ create_trigger_chain()
Make sure there is a chain for the specified event and action time.
- Returns
- A pointer to newly created Trigger_chain object, NULL in case of OOM error.
◆ disable_fields_temporary_nullability()
void Table_trigger_dispatcher::disable_fields_temporary_nullability |
( |
| ) |
|
Reset "temporary nullable" flag from trigger fields.
◆ enable_fields_temporary_nullability()
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.
- Parameters
-
◆ finalize_load()
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.
- Parameters
-
thd | current thread context |
- Returns
- Operation status.
- Return values
-
◆ find_trigger()
Get trigger object by trigger name.
- Parameters
-
[in] | trigger_name | trigger name |
- Returns
- a pointer to Trigger object, NULL if the trigger not found.
◆ get_subject_table()
TABLE * Table_trigger_dispatcher::get_subject_table |
( |
| ) |
|
|
inlineoverrideprivatevirtual |
◆ get_trigger_variable_field()
|
inlineoverrideprivatevirtual |
◆ get_triggers() [1/2]
Trigger_chain * Table_trigger_dispatcher::get_triggers |
( |
int |
event, |
|
|
int |
action_time |
|
) |
| |
|
inline |
◆ get_triggers() [2/2]
const Trigger_chain * Table_trigger_dispatcher::get_triggers |
( |
int |
event, |
|
|
int |
action_time |
|
) |
| const |
|
inline |
◆ has_delete_triggers()
bool Table_trigger_dispatcher::has_delete_triggers |
( |
| ) |
const |
|
inline |
◆ has_load_been_finalized()
bool Table_trigger_dispatcher::has_load_been_finalized |
( |
| ) |
|
|
inline |
Check whether we have finalized loading of triggers for the table by parsing their bodies, creating sp_head objects and preparing row-accessors.
◆ has_triggers()
◆ has_update_triggers()
bool Table_trigger_dispatcher::has_update_triggers |
( |
| ) |
const |
|
inline |
◆ mark_fields()
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.
- Parameters
-
event | Type of event triggers for which we are going to inspect |
- Returns
- false if success, true if error
◆ parse_triggers()
void Table_trigger_dispatcher::parse_triggers |
( |
THD * |
thd, |
|
|
List< Trigger > * |
triggers, |
|
|
bool |
is_upgrade |
|
) |
| |
Parse trigger definition statements (CREATE TRIGGER).
- Parameters
-
[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 |
◆ prepare_record1_accessors()
bool Table_trigger_dispatcher::prepare_record1_accessors |
( |
| ) |
|
|
private |
Prepare array of Field objects referencing to TABLE::record[1] instead of record<a href="they will represent OLD.
- row values in ON UPDATE trigger and in ON DELETE trigger which will be called during REPLACE execution" >0.
- Returns
- Operation status.
- Return values
-
◆ print_upgrade_warnings()
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.
- Parameters
-
◆ process_triggers()
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.
- Parameters
-
thd | Thread handle |
event | Insert, update or delete |
action_time | Before or after |
old_row_is_record1 | If record1 contains old or new field. |
- Returns
- Operation status.
- Return values
-
◆ set_parse_error_message()
void Table_trigger_dispatcher::set_parse_error_message |
( |
const char * |
error_message | ) |
|
|
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.
- Parameters
-
error_message | The error message thrown by the parser. |
◆ table_cache_unittest::Mock_share
friend class table_cache_unittest::Mock_share |
|
friend |
◆ m_load_finalized
bool Table_trigger_dispatcher::m_load_finalized |
|
private |
Indicates whether we have finalized loading of triggers for the table.
◆ m_new_field
Field** Table_trigger_dispatcher::m_new_field |
|
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).
◆ m_old_field
Field** Table_trigger_dispatcher::m_old_field |
|
private |
◆ m_parse_error_message
const char* Table_trigger_dispatcher::m_parse_error_message |
|
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().
- See also
- Table_trigger_dispatcher::set_parse_error()
◆ m_record1_field
Field** Table_trigger_dispatcher::m_record1_field |
|
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).
◆ m_subject_table
TABLE* Table_trigger_dispatcher::m_subject_table |
|
private |
TABLE instance for which this triggers list object was created.
◆ m_trigger_map
Triggers grouped by event, action_time.
The documentation for this class was generated from the following files: