Bug #81981 Basic automation functionality missing from prepared statements
Submitted: 23 Jun 2016 2:22 Modified: 23 Jun 2016 7:46
Reporter: Trey Raymond Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Prepared statements Severity:S3 (Non-critical)
Version:5.6, 5.7 OS:Any
Assigned to: CPU Architecture:Any
Tags: prepared statements, stored procedures, syntax

[23 Jun 2016 2:22] Trey Raymond
MySQL has long been missing some pretty essential commands in its prepared statement lexicon.  I know we've all been whining for years, but now that 5.7 is mature and still nothing, this needs to be addressed.

Picked the three biggest complaints for this report.  These go back a long ways (i.e. http://bugs.mysql.com/bug.php?id=42337) but are poorly documented.
The following commands need to be added to PREPARE support, and therefore stored procedure support (wouldn't make sense in other routine types, in any way I can think of).

in procs: no
in prepare: no
This is documented as separate from the basic prepare<->procedure syntax sharing, though it is missing from both.  See top line item:

in procs: no
in prepare: no
Complained about the loudest, as you can do a lot of neat stuff with dynamic triggers from procedures.  Generally also requires lock/unlock support mentioned above for change atomicity.

in procs: yes
in prepare: no
As this is supported in procs but not events, there's a hacky way to do it dynamically!  I'll plop that in 'how to repeat' - don't disable it as a risk (I'm sure many people are using the workaround), just fix the missing non-hacky support!

Support list for reference:

How to repeat:
example of hacky workaround here:

use test;
CREATE DEFINER=`root`@`localhost` EVENT `test_event` ON SCHEDULE EVERY 10 SECOND STARTS '2000-01-01 00:00:00' ON COMPLETION PRESERVE ENABLE DO select 1;
delimiter ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `event_hack_proc`()
insert into mysql.proc
set `db` ='test',
  `body`="alter definer='root'@'localhost' event test_event ON SCHEDULE EVERY 40 SECOND",
  `body_utf8`="alter definer='root'@'localhost' event test_event ON SCHEDULE EVERY 40 SECOND";
call tmp_proc();
delete from mysql.proc where db='test' and name='tmp_proc' and type='PROCEDURE';
delimiter ;
call event_hack_proc;
show create event test_event;

Suggested fix:
add the support already!  it's widely desired, and needed to be compatible in 2016, with stack reduction and automation as industry wide goals.  DB-layer admin procs are very popular and getting moreso.
it might not even be that hard to add!  seems like most of the work here would be testing, not really a lot of coding.
[23 Jun 2016 7:46] MySQL Verification Team
Hello Trey Raymond,

Thank you for the reasonable feature requests!