[freetds] [PATCH] Problem with VARCHAR in sybase.
James K. Lowden
jklowden at freetds.org
Mon Jun 30 23:13:23 EDT 2008
Eddy Pronk wrote:
> My database had a table with a column which was VARCHAR(20)
> One of the rows had exactly 20 characters.
> With a simple SELECT it hit this piece of code which returns CS_FAIL
> without logging anything:
> 538 case CS_FMT_NULLTERM:
> I included a patch below.
> If I allocate 1 byte extra for the null terminator my query works.
Thank you for the patch. You've highlighted a problem, but I don't think
your fix is the right one.
In the first place, ct-lib needs some time and attention paid to error
messages. There are many places where it works if used correctly but
fails silently (except for the return code) if not. We need a function
similar to dbperror().
Second, afaict CS_FMT_NULLTERM is invalid in cs_convert (cf.
Third, even if valid, istm the code is basically right: if the destination
buffer does not have room for a NULL terminator and the format
specification for the conversion demands one, the conversion should fail.
If I'm missing something, please explain.
More information about the FreeTDS