[ODBC-279] Binding parameter as SQL_C_TIME does not work correctly in some cases Created: 2020-04-20  Updated: 2020-06-30  Resolved: 2020-04-20

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: General
Affects Version/s: 3.1.7
Fix Version/s: 3.1.9

Type: Bug Priority: Major
Reporter: Lawrin Novitsky Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None


 Description   

Going about SQL_TYPE_TIME sql type in first turn, but again - not all cases. The test:

ODBC_TEST(timestruct_param)
{
SQL_TIMESTAMP_STRUCT ts=

{ 2020/*year*/, 4, 7, 1/*hour*/, 28, 56, 0/*fractional*/ }

;
SQL_TIME_STRUCT tp=

{15, 58, 33}

, tr;

CHECK_STMT_RC(Stmt, SQLBindParameter(Stmt, 1, SQL_PARAM_INPUT, SQL_C_TIME, SQL_TYPE_TIME, 8, 0, &tp, 0, NULL));
CHECK_STMT_RC(Stmt, SQLBindParameter(Stmt, 2, SQL_PARAM_INPUT, SQL_C_TIME, SQL_TYPE_TIME, 8, 0, &tp, 0, NULL));
CHECK_STMT_RC(Stmt, SQLBindParameter(Stmt, 3, SQL_PARAM_INPUT, SQL_C_TIME, SQL_TYPE_TIME, 8, 0, &tp, 0, NULL));
OK_SIMPLE_STMT(Stmt, "SELECT ?, CAST('15:58:33' AS TIME) = ?,

{t '15:58:33'}

= ?");
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));
CHECK_STMT_RC(Stmt, SQLGetData(Stmt, 1, SQL_C_TIME, &tr, sizeof(SQL_TIME_STRUCT), NULL));
is_num(tr.hour, 15);
is_num(tr.minute, 58);
is_num(tr.second, 33);
is_num(my_fetch_int(Stmt, 2), 1);
is_num(my_fetch_int(Stmt, 3), 1);
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_RESET_PARAMS));

CHECK_STMT_RC(Stmt, SQLBindParameter(Stmt, 1, SQL_PARAM_INPUT, SQL_C_TIMESTAMP, SQL_TYPE_TIMESTAMP, 20, 0, &ts, 0, NULL));
CHECK_STMT_RC(Stmt, SQLBindParameter(Stmt, 2, SQL_PARAM_INPUT, SQL_C_TIME, SQL_TYPE_TIME, 8, 0, &tp, 0, NULL));

OK_SIMPLE_STMT(Stmt, "SELECT 1 FROM DUAL WHERE '2020-04-07 01:28:56'=? AND CAST('15:58:33' AS TIME) = ?");
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));
is_num(my_fetch_int(Stmt, 1), 1);
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));

return OK;
}



 Comments   
Comment by Lawrin Novitsky [ 2020-04-20 ]

The fix and the testcase(even 2 testcases) pushed in the commit c83f334

Generated at Thu Feb 08 03:27:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.