Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to fetch empty string with ODBC driver #6690

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

Unable to fetch empty string with ODBC driver #6690

monetdb-team opened this issue Nov 30, 2020 · 0 comments

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2019-03-08 17:42:48 +0100
From: jpastuszek
To: clients devs <>
Version: 11.31.13 (Aug2018-SP2)

Last updated: 2019-04-30 12:36:04 +0200

Comment 26917

Date: 2019-03-08 17:42:48 +0100
From: jpastuszek

User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:66.0) Gecko/20100101 Firefox/66.0
Build Identifier:

ODBC SQLGetData call for empty string returns SQL_NO_DATA instead of empty string (buffer of "\0" or "\0\0" (UTF-16)) and SQL_SUCCESS result.

Reproducible: Always

Steps to Reproduce:

  1. Query "SELECT ''" and fetch
  2. Call SQLGetData for column 1 and type SQL_C_CHAR

Actual Results:

Returned result is SQL_NO_DATA

Expected Results:

Returned result is SQL_SUCCESS and buffer is filled with one NULL byte (two NULL bytes for WCHAR case).

https://github.com/MonetDB/MonetDB/blob/c1904ad32054585575e6e28028ae608435282cc6/clients/odbc/driver/ODBCConvert.cL1285

Probably the check if (irdrec->already_returned >= datalen) { will be true for first call of SQLGetData on empty string as both values will be 0. SQL_NO_DATA is returned immediately and copyString will not be called in this case.

My client works correctly with SQL Server. Documentation (https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgetdata-function?view=sql-server-2017) says "Returns SQL_NO_DATA if it has already returned all of the data for the column." which would suggest that SQL_NO_DATA should not be returned for the first time the SQLGetData is called.

Comment 26918

Date: 2019-03-08 18:30:01 +0100
From: MonetDB Mercurial Repository <>

Changeset 13337bea12f3 made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

For complete details, see https//devmonetdborg/hg/MonetDB?cmd=changeset;node=13337bea12f3

Changeset description:

First time fetching data for a column, return it, even if zero length.
Fix for bug #6690.

Comment 26919

Date: 2019-03-08 18:31:19 +0100
From: @sjoerdmullender

You completely nailed the problem. Fix was therefore easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant