Bug #46278 Checking ODBC connection option SQL_ATTR_CONNECTION_DEAD always returns 0
Submitted: 17 Jul 2009 23:52 Modified: 18 Jul 2009 1:41
Reporter: Rob Schuler Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51.15r409-4 OS:Any
Assigned to: CPU Architecture:Any
Tags: SQL_ATTR_CONNECTION_DEAD ODBC SQLGetConnectAttr

[17 Jul 2009 23:52] Rob Schuler
Description:
MySQL Connector/ODBC always indicates that the connection  is active even when it is dead. I have a service that connects to mysql via the odbc connector (using unixODBC manager). I can start my service run a query get valid results. Then stop the mysql service and on my next query, I begin by checking the connection status, and the value for SQL_ATTR_CONNECTION_DEAD returned by a call to SQLGetConnectAttr returns SQL_CD_FALSE (meaning the connection is alive).

How to repeat:
start mysql
start client
connect to mysql via odbc layer
stop mysql server
call something like:

"""
  SQLRETURN     r;
  SQLINTEGER    connection_dead;
  SQLINTEGER    buflen;

  r = SQLGetConnectAttr(h->dbc, SQL_ATTR_CONNECTION_DEAD,
          &connection_dead, SQL_IS_POINTER, &buflen);
"""

verify that connection_dead == SQL_CD_FALSE
[18 Jul 2009 1:41] Rob Schuler
Never mind I found a report that says 3.51.20+ has it fixed. Sorry