Bug #14863 Triggers: crash if create before use
Submitted: 11 Nov 2005 13:24 Modified: 6 Jan 2006 5:09
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.16-debug/5.0.17 BK OS:Linux (SUSE 10.0)
Assigned to: Dmitry Lenev CPU Architecture:Any

[11 Nov 2005 13:24] Peter Gulutzan
Description:
If I create a trigger before I say "USE database", crash.

How to repeat:
/* Assume database db88 exists. */

/* Start mysqld. Start client. do not say "USE database". */

mysql> create table db88.t89 (s1 int);
Query OK, 0 rows affected (0.06 sec)

mysql> create trigger tn89_bi before update on db88.t89 for each row set @a = 1;
ERROR 2013 (HY000): Lost connection to MySQL server during query
[11 Nov 2005 13:39] Miguel Solorzano
miguel@hegel:~/dbs/5.0> bin/mysqladmin -uroot create db88
miguel@hegel:~/dbs/5.0> bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.17-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create table db88.t89 (s1 int);
Query OK, 0 rows affected (0.04 sec)

mysql> create trigger tn89_bi before update on db88.t89 for each row set @a = 1;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> 

051111 11:39:12 [Note] /home/miguel/dbs/5.0/libexec/mysqld: ready for connections.
Version: '5.0.17-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
[New Thread 1132456880 (LWP 7064)]
[Thread 1132456880 (zombie) exited]
[New Thread 1132456880 (LWP 7066)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1132456880 (LWP 7066)]
0x4025334a in strcmp () from /lib/tls/libc.so.6
(gdb) bt full
#0  0x4025334a in strcmp () from /lib/tls/libc.so.6
No symbol table info available.
#1  0x085a9d95 in my_strcasecmp_bin (cs=0x87b2500, s=0x8e42aa0 "db88", t=0x0) at ctype-bin.c:232
No locals.
#2  0x0834828f in Table_triggers_list::create_trigger (this=0x8e42ab0, thd=0x8e41448, tables=0x8e6db60) at sql_trigger.cc:240
        lex = (LEX *) 0x8e41488
        table = (TABLE *) 0x8e2a5a8
        dir_buff = '\0' <repeats 20 times>, " 

<cut>
[27 Nov 2005 20:54] Karthik Viswanathan
Also try this case out :)

create trigger test before insert on mysql.user for each row begin end;

(create trigger mysql.test before insert on mysql.user for each row begin end; works!)

Expected behaviour: no database selected

(similiar to this, a CREATE PROCEDURE bug was fixed before)

Please fix ALL these errors (I'm beginning to lose my confidence on MySQL's robustness)
[11 Dec 2005 12:25] 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/64
[20 Dec 2005 12:15] Alexander Nozdrin
I like the patch.
[24 Dec 2005 21:11] Dmitry Lenev
Fixed in versions 5.0.18 and 5.1.5
[6 Jan 2006 5:09] Paul Dubois
Noted in 5.0.18, 5.1.5 changelogs.