Index: ChangeLog =================================================================== --- ChangeLog (revision 1116) +++ ChangeLog (working copy) @@ -7,8 +7,9 @@ the dialog box instead of SQL_NO_DATA. (Bug #36293) * System DSN lookup (using ODBC_BOTH_DSN) fails on Windows XP. (Bug #36203) - * A SQLProcedures followed by a SQLFreeStmt causes a crash - (Bug #36069) + * SQLProcedures() followed by SQLFreeStmt() crashes (Bug #36069) + * SQL_TYPE_TIMESTAMP and SQL_TYPE_TIME parameters were incorrectly + included when parameters were expanded. (Bug #37342) ---- Index: driver/execute.c =================================================================== --- driver/execute.c (revision 1115) +++ driver/execute.c (working copy) @@ -500,7 +500,7 @@ if (data[0] == '{') /* Of type {d date } */ { to= add_to_buffer(net, to, data, length); - break; + goto out; } /* else treat as a string */ case SQL_CHAR: @@ -524,6 +524,7 @@ to= add_to_buffer(net, to, dbc->ansi_charset_info->csname, strlen(dbc->ansi_charset_info->csname)); } + /* We have only added the introducer, data is added below. */ break; } case SQL_TIME: @@ -544,7 +545,7 @@ (int) time%100); to= add_to_buffer(net, to, buff, 10); } - break; + goto out; case SQL_FLOAT: case SQL_REAL: case SQL_DOUBLE: Index: test/my_datetime.c =================================================================== --- test/my_datetime.c (revision 1115) +++ test/my_datetime.c (working copy) @@ -897,6 +897,64 @@ } +/** + Bug #37342: ODBC TIMESTAMP string format not handled properly by ODBC driver +*/ +DECLARE_TEST(t_bug37342) +{ + SQLCHAR *date= (SQLCHAR *)"{dt '2007-01-13'}"; + SQLCHAR *time= (SQLCHAR *)"194759"; + SQLCHAR out[30]; + TIMESTAMP_STRUCT ts; + + ok_stmt(hstmt, SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, + SQL_TIMESTAMP, 0, 0, date, SQL_NTS, NULL)); + + ok_sql(hstmt, "SELECT ? AS foo"); + + ok_stmt(hstmt, SQLFetch(hstmt)); + + is_str(my_fetch_str(hstmt, out, 1), "2007-01-13", 11); + + expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA); + + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + + ok_stmt(hstmt, SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, + SQL_TYPE_TIME, 0, 0, time, SQL_NTS, NULL)); + + ok_sql(hstmt, "SELECT ? AS foo"); + + ok_stmt(hstmt, SQLFetch(hstmt)); + + is_str(my_fetch_str(hstmt, out, 1), "19:47:59", 9); + + expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA); + + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + + ok_stmt(hstmt, SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_TIMESTAMP, + SQL_TYPE_TIME, 0, 0, &ts, sizeof(ts), NULL)); + + ts.hour= 19; + ts.minute= 47; + ts.second= 59; + ts.fraction= 4; + + ok_sql(hstmt, "SELECT ? AS foo"); + + ok_stmt(hstmt, SQLFetch(hstmt)); + + is_str(my_fetch_str(hstmt, out, 1), "19:47:59", 9); + + expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA); + + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + + return OK; +} + + BEGIN_TESTS ADD_TEST(my_ts) ADD_TEST(t_tstotime) @@ -912,6 +970,7 @@ ADD_TEST(t_bug14414) ADD_TEST(t_bug30939) ADD_TEST(t_bug31009) + ADD_TEST(t_bug37342) END_TESTS