|
MySQL 5.6.14 Source Code Document
|
#include <sql_trigger.h>


Public Member Functions | |
| Table_triggers_list (TABLE *table_arg) | |
| bool | create_trigger (THD *thd, TABLE_LIST *table, String *stmt_query) |
| bool | drop_trigger (THD *thd, TABLE_LIST *table, String *stmt_query) |
| bool | process_triggers (THD *thd, trg_event_type event, trg_action_time_type time_type, bool old_row_is_record1) |
| bool | get_trigger_info (THD *thd, trg_event_type event, trg_action_time_type time_type, LEX_STRING *trigger_name, LEX_STRING *trigger_stmt, sql_mode_t *sql_mode, LEX_STRING *definer, LEX_STRING *client_cs_name, LEX_STRING *connection_cl_name, LEX_STRING *db_cl_name) |
| void | get_trigger_info (THD *thd, int trigger_idx, LEX_STRING *trigger_name, sql_mode_t *sql_mode, LEX_STRING *sql_original_stmt, LEX_STRING *client_cs_name, LEX_STRING *connection_cl_name, LEX_STRING *db_cl_name) |
| int | find_trigger_by_name (const LEX_STRING *trigger_name) |
| bool | has_triggers (trg_event_type event_type, trg_action_time_type action_time) |
| bool | has_delete_triggers () |
| void | set_table (TABLE *new_table) |
| void | mark_fields_used (trg_event_type event) |
| void | set_parse_error_message (char *error_message) |
| bool | add_tables_and_routines_for_triggers (THD *thd, Query_tables_list *prelocking_ctx, TABLE_LIST *table_list) |
| bool | is_fields_updated_in_trigger (MY_BITMAP *used_fields, trg_event_type event_type, trg_action_time_type action_time) |
Static Public Member Functions | |
| static bool | check_n_load (THD *thd, const char *db, const char *table_name, TABLE *table, bool names_only) |
| static bool | drop_all_triggers (THD *thd, char *db, char *table_name) |
| static bool | change_table_name (THD *thd, const char *db, const char *old_alias, const char *old_table, const char *new_db, const char *new_table) |
Static Public Member Functions inherited from Sql_alloc | |
| static void * | operator new (size_t size) throw () |
| static void * | operator new[] (size_t size) throw () |
| static void * | operator new[] (size_t size, MEM_ROOT *mem_root) throw () |
| static void * | operator new (size_t size, MEM_ROOT *mem_root) throw () |
| static void | operator delete (void *ptr, size_t size) |
| static void | operator delete (void *ptr, MEM_ROOT *mem_root) |
| static void | operator delete[] (void *ptr, MEM_ROOT *mem_root) |
| static void | operator delete[] (void *ptr, size_t size) |
Public Attributes | |
| TABLE * | trigger_table |
| GRANT_INFO | subject_table_grants [TRG_EVENT_MAX][TRG_ACTION_MAX] |
| List< LEX_STRING > | definitions_list |
| List< ulonglong > | definition_modes_list |
| List< LEX_STRING > | definers_list |
| List< LEX_STRING > | client_cs_names |
| List< LEX_STRING > | connection_cl_names |
| List< LEX_STRING > | db_cl_names |
Friends | |
| class | Item_trigger_field |
This class holds all information about triggers of table.
QQ: Will it be merged into TABLE in the future ?
Definition at line 59 of file sql_trigger.h.
| bool Table_triggers_list::add_tables_and_routines_for_triggers | ( | THD * | thd, |
| Query_tables_list * | prelocking_ctx, | ||
| TABLE_LIST * | 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. |
Definition at line 2183 of file sql_trigger.cc.

|
static |
Update .TRG and .TRN files after renaming triggers' subject table.
| [in,out] | thd | Thread context |
| [in] | db | Old database of subject table |
| [in] | old_alias | Old alias of subject table |
| [in] | old_table | Old name of subject table |
| [in] | new_db | New database for subject table |
| [in] | new_table | New name of subject table |
| FALSE | Success |
| TRUE | Error |
Definition at line 1998 of file sql_trigger.cc.

|
static |
Check whenever .TRG file for table exist and load all triggers it contains.
| thd | current thread context |
| db | table's database name |
| table_name | table's name |
| table | pointer to table object |
| names_only | stop after loading trigger names |
| False | success |
| True | error |
Definition at line 1156 of file sql_trigger.cc.


| bool Table_triggers_list::create_trigger | ( | THD * | thd, |
| TABLE_LIST * | tables, | ||
| String * | stmt_query | ||
| ) |
Create trigger for table.
| thd | current thread context (including trigger definition in LEX) | |
| tables | table list containing one open table for which the trigger is created. | |
| [out] | stmt_query | after successful return, this string contains well-formed statement for creation this trigger. |
| False | success |
| True | error |
Definition at line 628 of file sql_trigger.cc.

|
static |
Drop all triggers for table.
| thd | current thread context |
| db | schema for table |
| name | name for table |
| False | success |
| True | error |
Definition at line 1783 of file sql_trigger.cc.

| bool Table_triggers_list::drop_trigger | ( | THD * | thd, |
| TABLE_LIST * | tables, | ||
| String * | stmt_query | ||
| ) |
Drop trigger for table.
| thd | current thread context (including trigger definition in LEX) | |
| tables | table list containing one open table for which trigger is dropped. | |
| [out] | stmt_query | after successful return, this string contains well-formed statement for creation this trigger. |
| False | success |
| True | error |
Definition at line 999 of file sql_trigger.cc.
| bool Table_triggers_list::get_trigger_info | ( | THD * | thd, |
| trg_event_type | event, | ||
| trg_action_time_type | time_type, | ||
| LEX_STRING * | trigger_name, | ||
| LEX_STRING * | trigger_stmt, | ||
| sql_mode_t * | sql_mode, | ||
| LEX_STRING * | definer, | ||
| LEX_STRING * | client_cs_name, | ||
| LEX_STRING * | connection_cl_name, | ||
| LEX_STRING * | db_cl_name | ||
| ) |
Obtains and returns trigger metadata.
| thd | current thread context |
| event | trigger event type |
| time_type | trigger action time |
| trigger_name | returns name of trigger |
| trigger_stmt | returns statement of trigger |
| sql_mode | returns sql_mode of trigger |
| definer | returns definer/creator of trigger. The caller is responsible to allocate enough space for storing definer information. |
| False | success |
| True | error |
Definition at line 1610 of file sql_trigger.cc.
| bool Table_triggers_list::is_fields_updated_in_trigger | ( | MY_BITMAP * | used_fields, |
| trg_event_type | event_type, | ||
| trg_action_time_type | action_time | ||
| ) |
Check if any of the marked fields are used in the trigger.
| used_fields | Bitmap over fields to check |
| event_type | Type of event triggers for which we are going to inspect |
| action_time | Type of trigger action time we are going to inspect |
Definition at line 2231 of file sql_trigger.cc.
| void Table_triggers_list::mark_fields_used | ( | trg_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 |
Definition at line 2266 of file sql_trigger.cc.

| bool Table_triggers_list::process_triggers | ( | THD * | thd, |
| trg_event_type | event, | ||
| trg_action_time_type | time_type, | ||
| 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 | |
| event | |
| time_type | |
| old_row_is_record1 |
| FALSE | on success. |
| TRUE | on error. |
Definition at line 2113 of file sql_trigger.cc.

| void Table_triggers_list::set_parse_error_message | ( | char * | error_message | ) |
Signals to the Table_triggers_list that a parse error has occured when reading a trigger from file. This makes the Table_triggers_list enter an 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_triggers_list's table.
| error_message | The error message thrown by the parser. |
Definition at line 2303 of file sql_trigger.cc.

| void Table_triggers_list::set_table | ( | TABLE * | new_table | ) |
Adjust Table_triggers_list with new TABLE pointer.
| new_table | new pointer to TABLE instance |
Definition at line 1123 of file sql_trigger.cc.
| List<ulonglong> Table_triggers_list::definition_modes_list |
List of sql modes for triggers
Definition at line 135 of file sql_trigger.h.
| List<LEX_STRING> Table_triggers_list::definitions_list |
Field responsible for storing triggers definitions in file. It have to be public because we are using it directly from parser.
Definition at line 130 of file sql_trigger.h.
| GRANT_INFO Table_triggers_list::subject_table_grants[TRG_EVENT_MAX][TRG_ACTION_MAX] |
Grant information for each trigger (pair: subject table, trigger definer).
Definition at line 101 of file sql_trigger.h.
| TABLE* Table_triggers_list::trigger_table |
TABLE instance for which this triggers list object was created.
Definition at line 81 of file sql_trigger.h.