Modified:
trunk/ChangeLog
trunk/driver/results.c
trunk/test/my_use_result.c
Log:
Accessing the results of catalog functions could cause a crash when the
"Don't cache results" option was set and a forward-only cursor was
being used. (Bug #4657)
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-05-21 17:29:03 UTC (rev 429)
+++ trunk/ChangeLog 2007-05-21 18:15:03 UTC (rev 430)
@@ -3,6 +3,9 @@
Functionality added or changed:
Bugs fixed:
+ * Accessing the results of catalog functions could cause a crash when the
+ "Don't cache results" option was set and a forward-only cursor was
+ being used. (Bug #4657)
* SQL_WVARCHAR and SQL_WLONGVARCHAR parameters were not properly quoted
and escaped. (Bug #16235)
* SQLForeignKeys() did not properly escape wildcard characters in its
Modified: trunk/driver/results.c
===================================================================
--- trunk/driver/results.c 2007-05-21 17:29:03 UTC (rev 429)
+++ trunk/driver/results.c 2007-05-21 18:15:03 UTC (rev 430)
@@ -1293,8 +1293,13 @@
"Wrong fetchtype with FORWARD ONLY cursor",
0));
- if ( (stmt->dbc->flag & FLAG_NO_CACHE) )
+ if ((stmt->dbc->flag & FLAG_NO_CACHE))
+ {
+ if (stmt->result_array)
+ values= stmt->result_array + (cur_row * stmt->result->field_count);
+ else
values= mysql_fetch_row(stmt->result);
+ }
}
if ( if_dynamic_cursor(stmt) && set_dynamic_result(stmt) )
Modified: trunk/test/my_use_result.c
===================================================================
--- trunk/test/my_use_result.c 2007-05-21 17:29:03 UTC (rev 429)
+++ trunk/test/my_use_result.c 2007-05-21 18:15:03 UTC (rev 430)
@@ -70,8 +70,45 @@
}
+/**
+ Bug #4657: "Don't Cache Results" crashes when using catalog functions
+*/
+DECLARE_TEST(t_bug4657)
+{
+ SQLCHAR name[10];
+ SQLSMALLINT column_count;
+ SQLLEN name_length;
+
+ ok_stmt(hstmt, SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE,
+ (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY, 0));
+
+ ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug4657");
+ ok_sql(hstmt, "CREATE TABLE t_bug4657 (a INT)");
+
+ ok_stmt(hstmt, SQLTables(hstmt, (SQLCHAR *)"", SQL_NTS,
+ (SQLCHAR *)"", SQL_NTS,
+ (SQLCHAR *)"", SQL_NTS,
+ (SQLCHAR *)"TABLE,VIEW", SQL_NTS));
+
+ ok_stmt(hstmt, SQLNumResultCols(hstmt, &column_count));
+ is_num(column_count, 5);
+
+ ok_stmt(hstmt, SQLBindCol(hstmt, 3, SQL_C_CHAR, name, sizeof(name),
+ &name_length));
+ expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA_FOUND);
+
+ ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_UNBIND));
+ ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE));
+
+ ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug4657");
+
+ return OK;
+}
+
+
BEGIN_TESTS
ADD_TEST(t_use_result)
+ ADD_TEST(t_bug4657)
END_TESTS
| Thread |
|---|
| • Connector/ODBC 3.51 commit: r430 - in trunk: . driver test | jwinstead | 21 May |