[ODBC-111] SQLGetData() should allow a NULL TargetValuePtr to fetch the length Created: 2017-08-28  Updated: 2017-08-28  Resolved: 2017-08-28

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: None
Affects Version/s: 3.0.1
Fix Version/s: 3.0.1

Type: Bug Priority: Major
Reporter: Brad House Assignee: Lawrin Novitsky
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

Ubuntu 16.04, but not specific to Ubuntu



 Description   

In SQLGetData() in odbc_3_api.c, there is a check for if (TargetValuePtr == NULL) and if it is NULL, it returns HY009. However, it is common practice when fetching data from TEXT field to not know what buffer size is needed, and therefore simply pass NULL for TargetValuePtr and 0 for BufferLength to get the buffer size needed returned via StrLen_or_IndPtr then call SQLGetData() again with a sufficient buffer.

Simply commenting out this sanity check appears to work as expected.



 Comments   
Comment by Lawrin Novitsky [ 2017-08-28 ]

But what do we do with https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgetdata-function that explicitly states, that "TargetValuePtr cannot be NULL."?
Besides, there are other ways to get length of the data. Binding StrLen pointer, but not TargetValuePtr for the column with SQLBindCol is first, that comes on mind. And have that value right after fetch without any additional actions.
If you disagree, please re-open the bug

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