Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS always setting empty VARCHAR's to NULL

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS always setting empty VARCHAR's to NULL
  • Date: Fri, 26 Jun 2009 10:42:38 +0200

2009/6/23 Andrew Victor <avictor.za AT gmail.com>:
> hi,
>
>> It seems that calling ct_param() with an empty string (ie, data !=
>> NULL and datalen = 0), a NULL gets passed to the database rather than
>> an empty string.
>>
>> According to the Sybase documentation for ct_param:
>>
>>    "There are two ways to indicate a parameter with a null value:
>>     - Pass indicator as -1. In this case, data and datalen are ignored.
>>     - Pass data as NULL and datalen as 0 or CS_UNUSED"
>
> Attached is a patch (against 0.82) which should fix this.
>
>
> Regards,
>  Andrew Victor
>

I applied a modified version to CVS HEAD. I also updated lang_ct_param
test to test the bahavior. The patch works on mssql but not on Sybase.
The reason is that on Sybase len == 0 means NULL so we have two
options:
- libTDS should detect len == 0 and pass a single characters on the wire
- ctlib should replace empty to a single space
Perhaps it would be better to change libTDS.

TODO
- fix Sybase behavior
- update rpc_ct_param test
- check for ct_setparam updating ct_dynamic.c and rpc_ct_setparam.c
- backport to 0.82 ?? mainly I'm again, we backport only fixes

freddy77




Archive powered by MHonArc 2.6.24.

Top of Page