| 2751 | */ |
| 2752 | |
| 2753 | bool Table_triggers_list::process_triggers(THD *thd, |
| 2754 | trg_event_type event, |
| 2755 | trg_action_time_type time_type, |
| 2756 | bool old_row_is_record1, |
| 2757 | bool *skip_row_indicator, |
| 2758 | List<Item> *fields_in_update_stmt) |
| 2759 | { |
| 2760 | bool err_status; |
| 2761 | Sub_statement_state statement_state; |
| 2762 | Trigger *trigger; |
| 2763 | SELECT_LEX *save_current_select; |
| 2764 | |
| 2765 | /* |
| 2766 | skip_row_indicator != nullptr for BEFORE INSERT/UPDATE/DELETE triggers |
| 2767 | */ |
| 2768 | DBUG_ASSERT((time_type == TRG_ACTION_BEFORE && skip_row_indicator) || |
| 2769 | (time_type == TRG_ACTION_AFTER && !skip_row_indicator)); |
| 2770 | /* |
| 2771 | In case skip_indicator points to an out variable, its initial value |
| 2772 | must be false |
| 2773 | */ |
| 2774 | DBUG_ASSERT(!skip_row_indicator || |
| 2775 | (skip_row_indicator && *skip_row_indicator == false)); |
| 2776 | |
| 2777 | if (check_for_broken_triggers()) |
| 2778 | return TRUE; |
| 2779 | |
| 2780 | if (!(trigger= get_trigger(event, time_type))) |
| 2781 | return FALSE; |
| 2782 | |
| 2783 | if (old_row_is_record1) |
| 2784 | { |
| 2785 | old_field= record1_field; |
| 2786 | new_field= record0_field; |
| 2787 | } |
| 2788 | else |
| 2789 | { |
| 2790 | DBUG_ASSERT(event == TRG_EVENT_DELETE); |
| 2791 | new_field= record1_field; |
| 2792 | old_field= record0_field; |
| 2793 | } |
| 2794 | /* |
| 2795 | This trigger must have been processed by the pre-locking |
| 2796 | algorithm. |
| 2797 | */ |
| 2798 | DBUG_ASSERT(trigger_table->pos_in_table_list->trg_event_map & trg2bit(event)); |
| 2799 | |
| 2800 | if (time_type == TRG_ACTION_AFTER) |
| 2801 | thd->reset_sub_statement_state(&statement_state, SUB_STMT_TRIGGER); |
| 2802 | else |
| 2803 | /* |
| 2804 | For time type TRG_ACTION_BEFORE, set extra flag SUB_STMT_BEFORE_TRIGGER |
| 2805 | at sub statement state in addition to SUB_STMT_TRIGGER in order to |
| 2806 | be able to reset the m_sql_errno to the value |
| 2807 | ER_SIGNAL_SKIP_ROW_FROM_TRIGGER |
| 2808 | in case signal is raised with SQLSTATE "02TRG" from within a |
| 2809 | BEFORE trigger and don't modify m_sql_errno in case the signal is raised |
| 2810 | from AFTER trigger. |
no test coverage detected