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

Fix SQLGetDiagRec for length-only calls #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

staticlibs
Copy link
Contributor

According to ODBC spec:

If MessageText is NULL, TextLengthPtr will still return the
total number of characters (excluding the null-termination character
for character data) available to return in the buffer pointed to by
MessageText.

Such length-only calls are actually used by the Windows ODBC Driver Manager. Currently messages are returned in garbled form on Windows.

This change adds the logic to set the TextLengthPtr to the actual message length when the MessageText is specified as NULL.

Note: the impl still can be improved to handle partial message reads better (cover existing TODO there).

Testing: existing test is extended to cover this scenario.

Fixes: #56

According to ODBC spec:

> If `MessageText` is `NULL`, `TextLengthPtr` will still return the
> total number of characters (excluding the null-termination character
> for character data) available to return in the buffer pointed to by
> `MessageText`.

Such length-only calls are actually used by the Windows ODBC Driver
Manager. Currently messages are returned in garbled form on Windows.

This change adds the logic to set the `TextLengthPtr` to the actual
message length when the `MessageText` is specified as `NULL`.

Note: the impl still can be improved to handle partial message reads
better (cover existing TODO there).

Testing: existing test is extended to cover this scenario.

Fixes: duckdb#56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQLGetDiagRec is unable to return the error message on Windows
1 participant