Bug #6833 Triggers: crash with GOTO
Submitted: 25 Nov 2004 22:31 Modified: 27 Apr 2006 19:03
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.2-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Per-Erik Martin CPU Architecture:Any

[25 Nov 2004 22:31] Peter Gulutzan
Description:
A trigger can contain "goto w;" where w is not a label. This would be illegal in a function, a 
GOTO must have somewhere to go to. If I cause trigger activation, I see a crash. 
 

How to repeat:
mysql> create table t18 (s1 int)// 
Query OK, 0 rows affected (0.28 sec) 
 
mysql> create trigger t18_bi before insert on t18 for each row 
    -> begin 
    -> declare c cursor for select * from t18; 
    -> goto w; 
    -> end;// 
Query OK, 0 rows affected (0.65 sec) 
 
mysql> insert into t18 values (0)// 
ERROR 2013 (HY000): Lost connection to MySQL server during query
[26 Nov 2004 6:23] MySQL Verification Team
Verified with 5.0.2-alpha-debug-log

Back trace
(gdb) bt
#0  _checkchunk (irem=0x8d3c828, filename=0x85b3122 "my_alloc.c", lineno=194) at safemalloc.c:456
#1  0x08424067 in _sanity (filename=0x85b3122 "my_alloc.c", lineno=194) at safemalloc.c:490
#2  0x084234e7 in _mymalloc (size=24408, filename=0x85b3122 "my_alloc.c", lineno=194, MyFlags=16)
    at safemalloc.c:131
#3  0x08423149 in alloc_root (mem_root=0x8d2db38, Size=60) at my_alloc.c:194
#4  0x081418ec in sql_alloc (Size=60) at thr_malloc.cc:42
#5  0x0827bb5e in sp_rcontext::push_cursor (this=0x8d3aba8, lex=0x8d438a0) at sql_list.h:35
#6  0x08279957 in sp_instr_cpush::execute (this=0x8d41ce8, thd=0x8d2db28, nextp=0xbe5ff020) at sp_head.cc:1641
#7  0x082765d0 in sp_head::execute (this=0x8d41898, thd=0x8d2db28) at sp_head.cc:480
#8  0x08276972 in sp_head::execute_function (this=0x8d41898, thd=0x8d2db28, argp=0x0, argcount=0, resp=0x0)
    at sp_head.cc:588
#9  0x081c5fda in mysql_insert (thd=0x8d2db28, table_list=0x8d3a890, fields=@0x8d2df80,
    values_list=@0x8d2dfa0, update_fields=@0x8d2dd9c, update_values=@0x8d2df90, duplic=DUP_ERROR)
    at sql_trigger.h:52
#10 0x08181809 in mysql_execute_command (thd=0x8d2db28) at sql_parse.cc:2908
#11 0x0818544d in mysql_parse (thd=0x8d2db28, inBuf=0x8d3a820 "insert into t18 values (0)", length=26)
    at sql_parse.cc:4588
#12 0x0817e36f in dispatch_command (command=COM_QUERY, thd=0x8d2db28,
    packet=0x8d253a9 "insert into t18 values (0)", packet_length=27) at sql_parse.cc:1503
#13 0x0817dd28 in do_command (thd=0x8d2db28) at sql_parse.cc:1311
#14 0x0817d28a in handle_one_connection (arg=0x8d2db28) at sql_parse.cc:1047
#15 0xb7e4714b in pthread_start_thread () from /lib/libpthread.so.0
#16 0xb7e471df in pthread_start_thread_event () from /lib/libpthread.so.0
#17 0xb7d7a50a in clone () from /lib/libc.so.6
[1 Jul 2005 15:22] Per-Erik Martin
GOTO is disabled in 5.0.
[27 Apr 2006 19:03] Konstantin Osipov
GOTO support was removed from the code (5.0.21, 5.1.11)