Bug #3456 Incorrect error value on disconnect.
Submitted: 13 Apr 2004 7:16 Modified: 14 Sep 2007 12:43
Reporter: Fedor Baart Email Updates:
Status: Closed Impact on me:
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51/4.0.14 OS:Linux (linux 2.4)
Assigned to: Jim Winstead CPU Architecture:Any

[13 Apr 2004 7:16] Fedor Baart
When a client using ODBC gets disconnected after a wait-timeout the error value which is returned by the odbc driver is HY000. The error code which should be returned is HYT01 (or HYT00).

How to repeat:
Open a connection wait at least "wait-timeout" seconds without executing a query. Execute a query. The returned error code is HY000.

Suggested fix:
The returned error code should be HYT01 (or HYT00)
[10 Aug 2004 17:38] Reggie Burnett
The return ODBC state is 08S01 "Communication link failure".  This has been implemented and awaiting patch approval for pushing.
[11 Oct 2004 21:51] Harun Eren
After looking to the ODBC-Documentation, it is correct, the Funktion SQLExecute() must return an Error HYT00 for a query timeout. 
An application can check this.
see ODBC Documentation:
When SQLExecute returns
HYT00     Timeout expired      The query timeout period expired before the                
                                          data source  returned the result set. The  
                                          timeout period is set through                
                                          SQLSetStmtAttr,  SQL_ATTR_QUERY_TIMEOUT.
[16 Feb 2005 11:51] Alexander Barkov
Reggie, what is the current status of this bug?
Is it still not pushed? Where can I find the patch?
[24 Oct 2005 18:33] Peter Harvey
Fix not found. Need to check for CR_SERVER_LOST in the different locations where we try to connect. Reassigning to Sergey.
[8 Mar 2007 0:54] Jim Winstead
Sorry, we seem to have lost track of this bug report. This was reported as fixed in the ChangeLog for 3.51.10, but I'm not sure what was actually done. Re-opening so it will be re-verified.
[26 Mar 2007 9:40] Tonci Grgin
Yes, values are incorrect with 5.0.38-BK/MyODBC 3.51.14GA/WinXP Pro SP2 localhost:
 Error: [MySQL][ODBC 3.51 Driver][mysqld-5.0.38-log]MySQL server has gone away
 State: HY000
 nError: 2006
I would say SQLState should be *HYT01* for SQLExecDirect I used:
HYT01 	Connection timeout expired 	All ODBC functions except:


Same SQLState observed in mysql-connector-odbc-5.0-win32-nightly-20070322.zip.
[23 May 2007 18:42] Jim Winstead
Note: 08S01 is the correct SQLSTATE to return when the server drops the connection due to wait_timeout expiring, not HYT01. This is not a timeout under the control of the SQL_ATTR_CONNECTION_TIMEOUT or SQL_ATTR_QUERY_TIMEOUT attributes.
[30 May 2007 0:19] Kent Boortz
There is now a test case 't_bug3456' in "my_error.c",
that drops the connection and test what SQLSTATE is
[12 Sep 2007 22:49] Jim Winstead
Use correct SQLSTATE when connection lost

Attachment: bug3456.diff (text/plain), 1.26 KiB.

[13 Sep 2007 16:01] Jim Winstead
The fix for this bug has been committed to the source repository, and will be included in the next release (3.51.21).
[14 Sep 2007 12:43] MC Brown
A note has been added to the 3.51.21 changelog: 

Connector/ODBC would return the wrong the error code when the server disconnects the active connection because the configured wait_timeout has expired. Previously it would return HY000. Connector/ODBC now correctly returns an SQLSTATE of 08S01.