Bug #16394 Events: Crash if schedule contains SELECT
Submitted: 12 Jan 2006 3:30 Modified: 17 Sep 2006 5:32
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.1.6-alpha-debug OS:Linux (linux)
Assigned to: Andrey Hristov CPU Architecture:Any

[12 Jan 2006 3:30] Peter Gulutzan
Description:
In the event schedule clause, where perhaps a literal
timestamp is expected, I enter "(SELECT ...)". Crash.

How to repeat:
mysql> CREATE EVENT e_53 ON SCHEDULE AT (select s1 from ttx)  DO DROP TABLE t;
ERROR 2013 (HY000): Lost connection to MySQL server during query
[12 Jan 2006 8:07] Aleksey Kishkin
x80cc2ec handle_segfault + 680
0x825f6ea __pthread_sighandler + 122
0x810ed97 _Z12setup_tablesP3THDP23Name_resolution_contextP4ListI13st_table_listEPS4_PP4ItemPS7_b + 131
0x8117a60 _ZN4JOIN7prepareEPPP4ItemP13st_table_listjS1_jP8st_orderS7_S1_S7_P13st_select_lexP18st_select_lex_unit + 240
0x809f0d7 _ZN30subselect_single_select_engine7prepareEv + 309
0x809ba5b _ZN14Item_subselect10fix_fieldsEP3THDPP4Item + 109
0x81e2e21 _ZN11event_timed15init_execute_atEP3THDP4Item + 43
0x80eef37 _Z7yyparsePv + 3807
0x80ea9d9 _Z11mysql_parseP3THDPcj + 123
0x80e0354 _Z16dispatch_command19enum_server_commandP3THDPcj + 1152
0x80dfe88 _Z10do_commandP3THD + 154
0x80df219 handle_one_connection + 449
0x825b7b1 pthread_start_thread + 225
0x828a25a clone + 106
[5 Mar 2006 19:39] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/3478
[5 Mar 2006 19:43] Andrey Hristov
Back to verified, just added the patch to have it somewhere in a safe place.
[7 Mar 2006 11:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/3539
[7 Mar 2006 17:11] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/3545
[22 Mar 2006 14:48] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/4026
[26 Mar 2006 12:23] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/4171
[29 Jun 2006 9:54] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/8468
[21 Aug 2006 14:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/10682

ChangeSet@1.2281, 2006-08-21 16:52:16+02:00, andrey@example.com +3 -0
  Cleanup patch for handling of subselects in commands which cannot
  handle them.
  
  Problem:
  CREATE|ALTER EVENT, HANDLER READ, KILL, Partitioning uses `expr` from the
  parser. This rule comes with all the rings and bells including subqueries.
  However, these commands are not subquery safe. For this reason there are two
  fuse checks in the parser. They were checking by command id. CREATE EVENT
  should forbid subquery is the fix for
  bug#16394 Events: Crash if schedule contains SELECT
  The fix has been incorporated as part of the patch for WL#3337 (Event scheduler
  new architecture).
  
  Solution:
  A new flag was added to LEX command_forbids_subselect. The fuse checks were
  changed. The commands are responsible to set the value to true whenever
  they can't handle subselects.
[23 Aug 2006 0:15] Marc ALFF
Approved by email with minor comments
[15 Sep 2006 13:13] Dmitry Lenev
Fixed in 5.1.12

Fix for bug#16394 "Events: Crash if schedule contains SELECT"
  
Parsing of CREATE/ALTER EVENT statement was crashing because of early
initialization done during parsing, instead in the after parsing phase.
Moreover, we don't want SUBqueries in CREATE/ALTER EVENT therefore we
disable them, though it is possible to make them work. It can be emulated
inside SP with a cursor and SP variable (CREATE/ALTER EVENT can still
accept variables as values).
[17 Sep 2006 5:32] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented bugfix in 5.1.12 changelog. 

Also noted in Event Scheduler chapter that subselects are not allowed in an ON SCHEDULE clause.