Ad

How Mariadb/mysql Events Works Actually, In Case Of ON SCHEDULE EVERY 1 DAY ? And What Is The Use Of ENDS? Does It Completely Disable Event?

  CREATE EVENT test_event5
  ON SCHEDULE EVERY 1 DAY  
  STARTS  TIMESTAMP(CURRENT_DATE)+ INTERVAL 1 DAY 
  ENDS  TIMESTAMP(CURRENT_DATE)+ INTERVAL 1 DAY+ INTERVAL 1 HOUR
  ON COMPLETION PRESERVE ENABLE
  DO  --Any query here--

I have written this event but it I have a little confusion on STARTS date? What will be next STARTS and ENDS date after executing this. Suppose today is 2022-Jan-05, as per my code its STARTS and ENDS date will be 2022-Jan-06 which is next day. What will be the start date at 2022-Jan-06 ? Will it be change to 2022-Jan-07?

As per my understanding STARTS date be 2022-Jan-07 in the next day. What is the use of ENDS ?

Need expert opinion. Thanks in advance.

Ad

Answer

STARTS defines when the event will begin to be active and ENDS defines when the event ceases to execute. Both do not move or change, they are static values.

Your event will never execute outside this defined time window.

You define a time window during which your event is able to execute in intervals defined in ON SCHEDULE EVERY, given that ON COMPLETION PRESERVE is defined otherwise it will only execute once and then dropped.

Ad
source: stackoverflow.com
Ad