I am trying to write an automated test script for testing a MySQL Event that I created, and I am wondering if there is a way to execute some kind of command to force the Event to execute immediately. The Event is set to run daily at midnight, but I don't want the automated test script to have to wait for the Event to trigger.
我正在尝试编写一个自动测试脚本来测试我创建的MySQL事件,我想知道是否有办法执行某种命令来强制事件立即执行。事件设置为每天午夜运行,但我不希望自动测试脚本必须等待事件触发。
One way I can think of is to ALTER the Event to have it execute one-time 5 seconds into the future, but I'd like to know if there is a more elegant way to do get it to execute.
我能想到的一种方法是改变事件以使其在未来5秒内执行一次,但我想知道是否有更优雅的方法来执行它。
2 个解决方案
#1
15
- Move all the code within the event into a stored procedure
- Make the event only call the stored procedure
- Test the stored procedure with the CALL syntax.
将事件中的所有代码移动到存储过程中
使事件仅调用存储过程
使用CALL语法测试存储过程。
#2
0
if it is based on the system time, change that, and see if your event fires, then change the system time back.
如果它是基于系统时间,更改它,并查看您的事件是否触发,然后更改系统时间。
#1
15
- Move all the code within the event into a stored procedure
- Make the event only call the stored procedure
- Test the stored procedure with the CALL syntax.
将事件中的所有代码移动到存储过程中
使事件仅调用存储过程
使用CALL语法测试存储过程。
#2
0
if it is based on the system time, change that, and see if your event fires, then change the system time back.
如果它是基于系统时间,更改它,并查看您的事件是否触发,然后更改系统时间。