1551
MariaDBERRORNotableEventsHIGH confidence
Event execution time is in the past and ON COMPLETION NOT PRESERVE is set
Production Risk
Low — the event will be created but disabled; update the schedule.
What this means
ER_EVENT_EXEC_TIME_IN_THE_PAST (1551, SQLSTATE HY000) is raised when a one-time event is created with an AT timestamp in the past and ON COMPLETION NOT PRESERVE.
Why it happens
- 1CREATE EVENT AT past_timestamp where the timestamp has already passed
- 2On COMPLETION NOT PRESERVE means the event would execute then self-delete, but cannot since the time already passed
How to reproduce
trigger — this will error
trigger — this will error
CREATE EVENT one_time_event ON SCHEDULE AT '2020-01-01 00:00:00' -- In the past ON COMPLETION NOT PRESERVE DO SELECT 1;
expected output
ERROR 1551 (HY000): Event execution time is in the past. Event has been disabled but not dropped. You should either change execution time, enable [if needed] or drop the event
Fix
Use a future timestamp or ON COMPLETION PRESERVE
Use a future timestamp or ON COMPLETION PRESERVE
-- Use a future time: CREATE EVENT one_time_event ON SCHEDULE AT NOW() + INTERVAL 1 HOUR ON COMPLETION NOT PRESERVE DO SELECT 1; -- Or use PRESERVE to keep the event after execution: CREATE EVENT one_time_event ON SCHEDULE AT '2020-01-01 00:00:00' ON COMPLETION PRESERVE DO SELECT 1;
Why this works
Events with AT schedules must reference a future timestamp, or use ON COMPLETION PRESERVE.
Sources
Official documentation ↗
MySQL 8.0 — 1551 ER_EVENT_EXEC_TIME_IN_THE_PAST
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev