1 #ifndef SQL_TRIGGER_INCLUDED
2 #define SQL_TRIGGER_INCLUDED
25 class Query_tables_list;
27 class Query_tables_list;
47 enum trg_action_time_type
49 TRG_ACTION_BEFORE= 0, TRG_ACTION_AFTER= 1, TRG_ACTION_MAX
62 sp_head *bodies[TRG_EVENT_MAX][TRG_ACTION_MAX];
69 Field **record1_field;
115 bool m_has_unparseable_trigger;
123 char m_parse_error_message[MYSQL_ERRMSG_SIZE];
149 m_has_unparseable_trigger(false)
151 memset(bodies, 0,
sizeof(bodies));
160 trg_action_time_type time_type,
161 bool old_row_is_record1);
164 trg_action_time_type time_type,
166 sql_mode_t *sql_mode,
175 sql_mode_t *sql_mode,
181 int find_trigger_by_name(
const LEX_STRING *trigger_name);
187 const char *old_alias,
188 const char *old_table,
190 const char *new_table);
191 bool has_triggers(trg_event_type event_type,
192 trg_action_time_type action_time)
194 return (bodies[event_type][action_time] != NULL);
196 bool has_delete_triggers()
198 return (bodies[TRG_EVENT_DELETE][TRG_ACTION_BEFORE] ||
199 bodies[TRG_EVENT_DELETE][TRG_ACTION_AFTER]);
211 Query_tables_list *prelocking_ctx,
214 trg_event_type event_type,
215 trg_action_time_type action_time);
217 bool prepare_record1_accessors();
218 LEX_STRING* change_table_name_in_trignames(
const char *old_db_name,
219 const char *new_db_name,
222 bool change_table_name_in_triggers(THD *thd,
223 const char *old_db_name,
224 const char *new_db_name,
228 bool check_for_broken_triggers()
230 if (m_has_unparseable_trigger)
232 my_message(ER_PARSE_ERROR, m_parse_error_message, MYF(0));
239 extern const LEX_STRING trg_action_time_type_names[];
240 extern const LEX_STRING trg_event_type_names[];
242 bool add_table_for_trigger(THD *thd,
244 bool continue_if_not_exist,
249 bool check_trn_exists(
const LEX_STRING *trn_path);
251 bool load_table_name_for_trigger(THD *thd,
255 bool mysql_create_or_drop_trigger(THD *thd,
TABLE_LIST *tables,
bool create);
257 extern const char *
const TRG_EXT;
258 extern const char *
const TRN_EXT;