[ODBC-194] SQLGetData does not return SQL_NULL_DATA for date(time) types in some cases Created: 2018-10-29  Updated: 2018-11-14  Resolved: 2018-11-05

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: General
Affects Version/s: 3.0.6
Fix Version/s: 3.0.7, 2.0.19, 3.1.0

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


 Description   

Connector would not return NULL for 0000-00-00 datetime values in case
of SQLGetData call, while doing that in SQLFetch.

If empty string fetched as SQL_C_TIMESTAMP with SQLGetData, the result is not NULL.
Also for 0000-00-00 date(time) indicator value is not set to SQL_NULL_DATA
And today's date is returned. That is not important though.
If the same column is bound with SQL_C_TIMESTAMP buffer using SQLBindCol, the value is NULL. And that makes sense - select cast('' as datetime) will return you NULL.

To repeat is easy
OK_SIMPLE_STMT(Stmt, "SELECT ''");
CHECK_STMT_RC(Stmt, SQLBindCol(Stmt, 1, SQL_C_TIMESTAMP, &Datetime, sizeof(SQL_TIMESTAMP_STRUCT), &sInd));
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));
is_num(sInd, SQL_NULL_DATA);



 Comments   
Comment by Lawrin Novitsky [ 2018-11-05 ]

Commit ae8467a in master/odbc-3.0 and develop. Yet to be merged/cherry-picked to odbc-2.0

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