This class holds all information about triggers of a table.
More...
#include <table_trigger_dispatcher.h>
|
bool | check_n_load (THD *thd, const dd::Table &table) |
| Load triggers for the table. More...
|
|
bool | reorder_57_list (MEM_ROOT *mem_root, List< Trigger > *triggers) |
|
| ~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...
|
|
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. |
◆ check_n_load()
bool Table_trigger_dispatcher::check_n_load |
( |
THD * |
thd, |
|
|
const dd::Table & |
table |
|
) |
| |
Load triggers for the table.
- Parameters
-
thd | current thread context |
table | table object. |
- Returns
- Operation status.
- Return values
-
◆ 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
-
◆ 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_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
-
◆ reorder_57_list()
bool Table_trigger_dispatcher::reorder_57_list |
( |
MEM_ROOT * |
mem_root, |
|
|
List< Trigger > * |
triggers |
|
) |
| |
◆ set_parse_error_message()
void Table_trigger_dispatcher::set_parse_error_message |
( |
const char * |
error_message | ) |
|
|
inlineprivate |
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_has_unparseable_trigger == true. 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. |
◆ m_has_unparseable_trigger
bool Table_trigger_dispatcher::m_has_unparseable_trigger |
|
private |
This flag indicates that one of the triggers was not parsed successfully, and as a precaution the object has entered the state where all trigger operations result in errors 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().
We can't use the value of m_parse_error_message as a flag to inform that a trigger has a parse error since for multi-byte locale the first byte of message can be 0 but the message still be meaningful. It means that just a comparison against m_parse_error_message[0] can not be done safely.
- See also
- Table_trigger_dispatcher::set_parse_error()
◆ 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
This error will be displayed when the user tries to manipulate or invoke triggers on a table that has broken triggers.
It is set once per statement and thus will contain the first parse error encountered in the trigger file.
◆ 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: