Modified:
trunk/ChangeLog
trunk/driver/options.c
trunk/test/my_info.c
Log:
Fixed the bug related to incorrect reporting of dead connections
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-09-06 18:52:17 UTC (rev 746)
+++ trunk/ChangeLog 2007-09-06 22:10:14 UTC (rev 747)
@@ -14,6 +14,8 @@
when no data left, even if requested size is 0. (Bug#30520)
* SQLSetParam() caused memory allocation errors due to driver manager's
mapping of deprecated functions (buffer length -1). (Bug#29871)
+ * SQLGetConnectAttr() did not reflect the connection state correctly.
+ (Bug#14639)
----
Modified: trunk/driver/options.c
===================================================================
--- trunk/driver/options.c 2007-09-06 18:52:17 UTC (rev 746)
+++ trunk/driver/options.c 2007-09-06 22:10:14 UTC (rev 747)
@@ -451,7 +451,13 @@
case SQL_ATTR_CONNECTION_DEAD:
{
- if ( mysql_ping( &dbc->mysql ) && mysql_errno(
&dbc->mysql ) == CR_SERVER_LOST )
+ /*
+ We have to check for both CR_SERVER_LOST and
+ CR_SERVER_GONE_ERROR to report about dead connections
+ */
+ if ( mysql_ping( &dbc->mysql ) &&
+ (mysql_errno( &dbc->mysql ) == CR_SERVER_LOST ||
+ mysql_errno( &dbc->mysql ) == CR_SERVER_GONE_ERROR) )
*((SQLUINTEGER *) ValuePtr)= SQL_CD_TRUE;
else
*((SQLUINTEGER *) ValuePtr)= SQL_CD_FALSE;
Modified: trunk/test/my_info.c
===================================================================
--- trunk/test/my_info.c 2007-09-06 18:52:17 UTC (rev 746)
+++ trunk/test/my_info.c 2007-09-06 22:10:14 UTC (rev 747)
@@ -153,7 +153,40 @@
#endif
}
+DECLARE_TEST(t_bug14639)
+{
+ SQLINTEGER connection_id;
+ SQLUINTEGER is_dead;
+ char buf[100];
+ SQLHENV henv2;
+ SQLHDBC hdbc2;
+ SQLHSTMT hstmt2;
+ /* Create a new connection that we deliberately will kill */
+ alloc_basic_handles(&henv2, &hdbc2, &hstmt2);
+ ok_sql(hstmt2, "SELECT connection_id()");
+ ok_stmt(hstmt2, SQLFetch(hstmt2));
+ connection_id= my_fetch_int(hstmt2, 1);
+ ok_stmt(hstmt2, SQLFreeStmt(hstmt2, SQL_CLOSE));
+
+ /* Check that connection is alive */
+ ok_con(hdbc2, SQLGetConnectAttr(hdbc2, SQL_ATTR_CONNECTION_DEAD, &is_dead,
+ sizeof(is_dead), 0));
+ is(is_dead == SQL_CD_FALSE)
+
+ /* From another connection, kill the connection created above */
+ sprintf(buf, "KILL %d", connection_id);
+ ok_stmt(hstmt, SQLExecDirect(hstmt, (SQLCHAR *)buf, SQL_NTS));
+
+ /* Now check that the connection killed returns the right state */
+ ok_con(hdbc, SQLGetConnectAttr(hdbc2, SQL_ATTR_CONNECTION_DEAD, &is_dead,
+ sizeof(is_dead), 0));
+ is(is_dead == SQL_CD_TRUE)
+
+ return OK;
+}
+
+
BEGIN_TESTS
ADD_TEST(sqlgetinfo)
ADD_TEST(t_gettypeinfo)
@@ -161,6 +194,7 @@
ADD_TEST(t_msdev_bug)
ADD_TEST(t_bug27591)
ADD_TEST(t_bug28657)
+ ADD_TEST(t_bug14639)
END_TESTS
| Thread |
|---|
| • Connector/ODBC 3.51 commit: r747 - in trunk: . driver test | bdegtyariov | 7 Sep |