Skip to Content.
Sympa Menu

freetds - Re: [freetds] [PATCH] Problem with VARCHAR in sybase.

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] [PATCH] Problem with VARCHAR in sybase.
  • Date: Mon, 30 Jun 2008 23:13:23 -0400

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.
http://manuals.sybase.com:80/onlinebooks/group-oc/ocg1250e/occpr/@ebt-link;pt=2420?target=%25N%14_2686_START_RESTART_N%25).


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.

Regards,

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page