mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-10164: Add support for TRIGGERS that fire on multiple events
Added capability to create a trigger associated with several trigger events. For this goal, the syntax of the CREATE TRIGGER statement was extended to support the syntax structure { event [ OR ... ] } for the `trigger_event` clause. Since one trigger will be able to handle several events it should be provided a way to determine what kind of event is handled on execution of a trigger. For this goal support of the clauses INSERTING, UPDATING , DELETING was added by this patch. These clauses can be used inside a trigger body to detect what kind of trigger action is currently processed using the following boilerplate: IF INSERTING THEN ... ELSIF UPDATING THEN ... ELSIF DELETING THEN ... In case one of the clauses INSERTING, UPDATING, DELETING specified in a trigger's body not matched with a trigger event type, the error ER_INCOMPATIBLE_EVENT_FLAG is emitted. After this patch be pushed, one Trigger object will be associated with several trigger events. It means that the array Table_triggers_list::triggers can contain several pointers to the same Trigger object in array members corresponding to different events. Moreover, support of several trigger events for the same trigger requires that the data members `next` and `action_order` of the Trigger class be converted to arrays to store relating information per trigger event base. Ability to specify the same trigger for different event types results in necessity to handle invalid cases on execution of the multi-event trigger, when the OLD or NEW qualifiers doesn't match a current event type against that the trigger is run. The clause OLD should produces the NULL value for INSERT event, whereas the clause NEW should produce the NULL value for DELETE event.
This commit is contained in:
@@ -33,7 +33,7 @@ Field Type Null Key Default Extra
|
||||
TRIGGER_CATALOG varchar(512) NO NULL
|
||||
TRIGGER_SCHEMA varchar(64) NO NULL
|
||||
TRIGGER_NAME varchar(64) NO NULL
|
||||
EVENT_MANIPULATION varchar(6) NO NULL
|
||||
EVENT_MANIPULATION varchar(20) NO NULL
|
||||
EVENT_OBJECT_CATALOG varchar(512) NO NULL
|
||||
EVENT_OBJECT_SCHEMA varchar(64) NO NULL
|
||||
EVENT_OBJECT_TABLE varchar(64) NO NULL
|
||||
@@ -58,7 +58,7 @@ TRIGGERS CREATE TEMPORARY TABLE `TRIGGERS` (
|
||||
`TRIGGER_CATALOG` varchar(512) NOT NULL,
|
||||
`TRIGGER_SCHEMA` varchar(64) NOT NULL,
|
||||
`TRIGGER_NAME` varchar(64) NOT NULL,
|
||||
`EVENT_MANIPULATION` varchar(6) NOT NULL,
|
||||
`EVENT_MANIPULATION` varchar(20) NOT NULL,
|
||||
`EVENT_OBJECT_CATALOG` varchar(512) NOT NULL,
|
||||
`EVENT_OBJECT_SCHEMA` varchar(64) NOT NULL,
|
||||
`EVENT_OBJECT_TABLE` varchar(64) NOT NULL,
|
||||
@@ -83,7 +83,7 @@ Field Type Null Key Default Extra
|
||||
TRIGGER_CATALOG varchar(512) NO NULL
|
||||
TRIGGER_SCHEMA varchar(64) NO NULL
|
||||
TRIGGER_NAME varchar(64) NO NULL
|
||||
EVENT_MANIPULATION varchar(6) NO NULL
|
||||
EVENT_MANIPULATION varchar(20) NO NULL
|
||||
EVENT_OBJECT_CATALOG varchar(512) NO NULL
|
||||
EVENT_OBJECT_SCHEMA varchar(64) NO NULL
|
||||
EVENT_OBJECT_TABLE varchar(64) NO NULL
|
||||
|
Reference in New Issue
Block a user