Bug #34780 Events: set event_scheduler=off is allowed inside an event and stops the schedul
Submitted: 23 Feb 2008 22:13 Modified: 8 Oct 2008 20:01
Reporter: Peter Laursen (Basic Quality Contributor) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: qc

[23 Feb 2008 22:13] Peter Laursen
Description:
I find it problematic that an EVENT can 
"SET GLOBAL event_scheduler = off;"

the example below will NOT execute "every 5 minute" !

How to repeat:
DELIMITER $$

SET GLOBAL event_scheduler = ON $$  		

CREATE
EVENT `test`.`test`

ON SCHEDULE
        EVERY 5 MINUTE
	STARTS CURRENT_TIMESTAMP
	ENABLE

DO 
	BEGIN
	SET GLOBAL event_scheduler = off;
	END $$

DELIMITER ;

Suggested fix:
... hmmm .. I would consider disabling "SET GLOBAL event_scheduler" from inside an EVENT.

This is not a silly as it seems in my opinion, because if an EVENT executes a Stored procdure that executes ... then eventscheduler could inadvertedly be disabled!
[24 Feb 2008 5:47] Valeriy Kravchuk
Thank you for a problem report. It looks like execution of this SET statement should be prevented if called from event...
[24 Feb 2008 12:47] Peter Laursen
I think it 'not a real bug'.

http://dev.mysql.com/doc/refman/5.1/en/create-event.html
says
"In addition, if the event's definer has the SUPER privilege, that event may read and write global variables. As granting this privilege entails a potential for abuse, extreme care must be taken in doing so."

.. so it is documented like that.  But in the particular situation with "SET EVENT_SCHEDULER .." it is like removing the chair where you sit!
[24 Feb 2008 13:16] Peter Laursen
something related here:
http://bugs.mysql.com/bug.php?id=34787
[24 Feb 2008 13:31] Peter Laursen
And I do think that event_scheduler setting needs better protection than most server variables.

If you use EVENTs, it can be very critical if they get disabled!
[25 Feb 2008 19:42] Timothy Smith
Peter,

Thank you for the report.  We do agree that this is less than optimal behavior, but it works as documented currently.  Adding this restriction would be a useful feature to improve usability.

Regards,

Timothy
[6 Mar 2008 16:54] Andrey Hristov
For me that's a bogus report. One can also empty mysql.event from an event that has SUPER and then complain why TRUNCATE or DELETE is available in the body of an event.
[8 Oct 2008 20:01] Konstantin Osipov
This is documented. Generally MySQL provides many ways to shoot oneself in the foot, and is quite liberal in that.