[freetds] SQL_SUCCESS_WITH[out]_INFO in ODBC lib
Nathan Bird
nathan at acceleration.net
Thu Apr 10 14:41:38 EDT 2008
I ran into a problem recently where trying to read data through the ODBC
lib gave me a number of problems, updating to 0.82RC4 fixed most of
them, but one remains.
Reading data in chunks with SQLGetData if the buffer is not long enough
for the value to copy, it should fill the buffer, and return
SQL_SUCCESS_WITH_INFO, along with setting the StrLen_or_IndPtr to point
at the how much data is available. At least according to
http://msdn2.microsoft.com/en-us/library//ms715441.aspx [1] the info
should be "01004" to indicate the string is right truncated-- this isn't
being set right now.
SQLGetData is defined in src/odbc/odbc.c line 4617 [2], there is a note
on 4717, "TODO: add diagnostic"... I think if that were replaced with
something like
odbc_errs_add(&stmt->errs, "01004", NULL);
that would be pretty much taken care of. As I understand it, at that
branch it is already only dealing with character (or binary) data so
that is about all that is applicable.
I am working with some code that depended on that status being set to
indicate it should continue querying for more data. I've changed this to
just keep querying as long as it is success_with_info, and the size
pointer indicates there is more data. Having this flag set as well would
still be nice and may save someone else the trouble.
[1] From my searching this was the most definitive source for ODBC spec
I could find, if there is a better source please let me know.
[2]
http://freetds.cvs.sourceforge.net/freetds/freetds/src/odbc/odbc.c?revision=1.478&view=markup
Nathan Bird
More information about the FreeTDS
mailing list