Bug #22158 Errors in init_connect terminate connections silently
Submitted: 9 Sep 2006 8:37 Modified: 24 Jan 2007 0:26
Reporter: Hartmut Holzgraefe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.0bk OS:Linux (linux)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[9 Sep 2006 8:37] Hartmut Holzgraefe
Description:
An init_connect SQL string that produces an error for whatever reason terminates the connection silently without giving any clue to the connected client or the servers error log

How to repeat:
start mysqld with   

  mysqld [...] --init-connect="SELECT * FORM nonexistant_table;"

connect as a non-SUPER user:

> mysql -u foo test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.26-debug

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

mysql> SELECT VERSION();
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    2
Current database: test

ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    3
Current database: test

ERROR 2006 (HY000): MySQL server has gone away

so the error message given to the client does not indicate what was actually going wrong and there is nothing in the servers error log either

Suggested fix:
produce a meaningfull error message in the server error log at least
[24 Oct 2006 8: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/14228

ChangeSet@1.2323, 2006-10-24 13:39:03+05:00, ramil@mysql.com +1 -0
  Fix for bug #22158: Errors in init_connect terminate connections silently
  
  We set thd->net.vio= 0 to forbid sending result of the 
  init_connect execution to client. As a side effect we don't 
  log possible errors.
[26 Oct 2006 11:22] 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/14418

ChangeSet@1.2323, 2006-10-26 14:51:34+05:00, ramil@mysql.com +1 -0
  Fix for bug #22158: Errors in init_connect terminate connections silently
  
  When executing the init_connect statement, thd->net.vio is set to 0, to         
  forbid sending any results to the client. As a side effect we don't log         
  possible errors, either.                                                        
                                                                                  
  Now we write warnings to the error log if an init_connect query                
  fails.
[24 Jan 2007 0:26] Paul Dubois
Noted in 5.0.30, 5.1.13 changelogs.

If an init_connect SQL statement produced an error, the connection
was silently terminated with no error message. Now the server writes
a warning to the error log.