Details
-
New Feature
-
Status: Stalled (View Workflow)
-
Critical
-
Resolution: Unresolved
-
Q1/2026 Server Development, Q2/2026 Server Maintenance, Q2/2026 Server Development, Q3/2026 Server Development, Q4/2026 Server Maintenance
Description
To create a system trigger on start up/shut down the following statement should be executed:
CREATE TRIGGER [IF NOT EXISTS] trigger_name AFTER STARTUP trigger_body |
CREATE TRIGGER [IF NOT EXISTS] trigger_name BEFORE SHUTDOWN trigger_body |
To drop a system trigger, the regular DROP TRIGGER statement is used.
The SUPER privilege is required to create or drop a system trigger.
A system trigger is created in the schema that is current at the moment the CREATE TRIGGER statement executed.
Metadata of system trigger is stored at the table mysql.event. To store system trigger metadata this table is extended with the following columns:
kind, when, ddl_type
For real event the column kind has the value 'SCHEDULE', for on startup and on shutdown the values are 'STARTUP', 'SHUTDOWN' correspondingly.
The table mysql.event has the primary on columns (`db`,`name`). In result, it is not possible to create an event and a system trigger with name in the same database. Attempt to do it will fail with the error ER_TRG_EVENT_CONFLICTS_NAME
Implementation of the statements
SHOW TRIGGERS
|
SHOW CREATE TRIGGER |
are modified to handle system triggers.
During server start up on startup/on shutdown system triggers are loaded by opening the table mysql.event and fetching every row for which the values in the column kind matches the values 'STARTUP', 'SHUTDOWN'. Based on retrieved data, instances of the class Sys_trigger are created and stored in lists accessed by two-dimensional array (sys_triggers) indexed by trigger time (BEFORE, AFTER) and kind (STARTUP, SHUTDOWN). This array is singleton by its nature. Access to the array is protected by the global mutex. After startup process finished, the AFTER STARTUP triggers loaded during server initiailization are executed. The same is for ON SHUTDOWN triggers: on receiving shutdown request, every trigger stored in the array sys_triggers for BEFORE/SHUTDOWN combination are executed.
The utility program mariadb-dump is patched to support dumping of system triggers.
In case server is started on the data dictionary with broken structure of the table mysql.event (for example, missed some columns required for storing trigger's metadata), running of server will be failed with error complaining on wrong structure of the table mysql.event.
To fix the issue, start server with the option --skip-grant-tables.
The another case is attempt to start up server on the data dictionary created by previous version of MariaDB server (without support of system triggers). Starting the server on previous version of the table mysql.event result in success running the server but with disabled feature for system triggers.
Attachments
Issue Links
- causes
-
MDEV-40064 Memory leak with unparseble trigger for startup body
-
- Stalled
-
-
MDEV-40067 mysqldump --sys-triggers creates unloadable dump
-
- In Review
-
-
MDEV-40071 Assertion `ret == false' failed in mysql_drop_sys_or_ddl_trigger
-
- In Review
-
-
MDEV-40072 Server crashes in my_hash_first/name_hash_search after load_system_triggers
-
- In Progress
-
-
MDEV-40074 Create or replace does not work for trigger for startup/shutdown
-
- In Review
-
-
MDEV-40076 ASAN global-buffer-overflow in reconstruct_create_trigger_stmt
-
- In Review
-
-
MDEV-40083 Compound triggers for startup/shutdown are stored without END, which leads to silent non-firing after restart
-
- Approved
-
-
MDEV-40091 ASAN: heap-use-after-free with concurrent create/drop system trigger
-
- Stalled
-
-
MDEV-40095 Server doesn't start if system triggers not loaded (if cannot open mysql.event)
-
- In Review
-
-
MDEV-40104 Triggers after startup/before shutdown are replicated as ENABLEd, which may lead to divergence
-
- Open
-
-
MDEV-40105 Information_schema.triggers doesn't show schema for system triggers
-
- In Review
-
-
MDEV-40106 Sever crashes in store_trigger_metadata after 2nd execution of ps with create system trigger
-
- In Review
-
-
MDEV-40947 ASAN global-buffer-overflow in events_to_string/reconstruct_create_trigger_stmt
-
- In Review
-
-
MDEV-40951 System triggers give no visibility into slow/failed execution and misreport server readiness
-
- Open
-
-
MDEV-40952 CREATE TRIGGER fails with ER_EVENT_STORE_FAILED after unrelated failed ALTER
-
- In Review
-
- includes
-
MDEV-36006 Implement generalized triggers 2
-
- Closed
-
- relates to
-
MDEV-37488 Adapting innodb_buffer_pool_dump_pct from innodb_old_blocks_pct
-
- Open
-
-
MDEV-30643 Allow CONCAT in SIGNAL
-
- Open
-
- has action item
-
DOCS-6220 Loading...