Modified:
trunk/ChangeLog
trunk/driver/catalog.c
trunk/test/my_datetime.c
Log:
SQLSpecialColumns() returned all TIMESTAMP fields when queried for
SQL_ROWVER, not just an auto-updating TIMESTAMP field. (Bug #9927, still
limited by Bug #30081 in the server.)
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-30 15:27:03 UTC (rev 611)
+++ trunk/ChangeLog 2007-07-30 15:29:36 UTC (rev 612)
@@ -7,6 +7,9 @@
ODBC logging should be used.
Bugs fixed:
+ * SQLSpecialColumns() returned all TIMESTAMP fields when queried for
+ SQL_ROWVER, not just an auto-updating TIMESTAMP field. (Bug #9927, still
+ limited by Bug #30081 in the server.)
* SQLConnect() and SQLDriverConnect() were rewritten to eliminate duplicate
code and ensure all options were supported using both connection methods.
SQLDriverConnect() now only requires the setup library to be present when
Modified: trunk/driver/catalog.c
===================================================================
--- trunk/driver/catalog.c 2007-07-30 15:27:03 UTC (rev 611)
+++ trunk/driver/catalog.c 2007-07-30 15:29:36 UTC (rev 612)
@@ -1545,8 +1545,15 @@
(field = mysql_fetch_field(result)); )
{
int type;
- if ( (field->type != MYSQL_TYPE_TIMESTAMP) )
- continue;
+ if ((field->type != MYSQL_TYPE_TIMESTAMP))
+ continue;
+ /*
+ TIMESTAMP_FLAG is only set on fields that are auto-set or
+ auto-updated. We really only want auto-updated, but we can't
+ tell the difference because of Bug #30081.
+ */
+ if (!(field->flags & TIMESTAMP_FLAG))
+ continue;
field_count++;
sprintf(buff,"%d",SQL_SCOPE_SESSION);
row[0]= strdup_root(alloc,buff);
Modified: trunk/test/my_datetime.c
===================================================================
--- trunk/test/my_datetime.c 2007-07-30 15:27:03 UTC (rev 611)
+++ trunk/test/my_datetime.c 2007-07-30 15:29:36 UTC (rev 612)
@@ -686,6 +686,61 @@
}
+/**
+ Bug #9927: Updating datetime columns
+*/
+DECLARE_TEST(t_bug9927)
+{
+ SQLCHAR col[10];
+
+ ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug9927");
+ ok_sql(hstmt,
+ "CREATE TABLE t_bug9927 (a TIMESTAMP DEFAULT 0,"
+ "b TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)");
+
+ ok_stmt(hstmt, SQLSpecialColumns(hstmt,SQL_ROWVER, NULL, 0,
+ NULL, 0, (SQLCHAR *)"t_bug9927", SQL_NTS,
+ 0, SQL_NO_NULLS));
+
+ ok_stmt(hstmt, SQLFetch(hstmt));
+
+ is_str(my_fetch_str(hstmt, col, 2), "b", 1);
+
+ expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA_FOUND);
+
+ ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE));
+
+ ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug9927");
+
+ return OK;
+}
+
+
+/**
+ Bug #30081: Can't distinguish between auto-set TIMESTAMP and auto-updated
+ TIMESTAMP
+*/
+DECLARE_TEST(t_bug30081)
+{
+ SQLCHAR col[10];
+
+ ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug30081");
+ ok_sql(hstmt,
+ "CREATE TABLE t_bug30081 (a TIMESTAMP DEFAULT 0,"
+ "b TIMESTAMP DEFAULT CURRENT_TIMESTAMP)");
+
+ ok_stmt(hstmt, SQLSpecialColumns(hstmt,SQL_ROWVER, NULL, 0,
+ NULL, 0, (SQLCHAR *)"t_bug30081", SQL_NTS,
+ 0, SQL_NO_NULLS));
+
+ expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA_FOUND);
+
+ ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE));
+
+ ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug30081");
+
+ return OK;
+}
BEGIN_TESTS
ADD_TEST(my_ts)
ADD_TEST(t_tstotime)
@@ -695,6 +750,8 @@
ADD_TEST(t_time1)
ADD_TEST(t_bug12520)
ADD_TEST(t_bug15773)
+ ADD_TEST(t_bug9927)
+ ADD_TODO(t_bug30081)
END_TESTS
| Thread |
|---|
| • Connector/ODBC 3.51 commit: r612 - in trunk: . driver test | jwinstead | 30 Jul |