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

Frediano Ziglio freddy77 at gmail.com
Fri Jun 26 04:42:38 EDT 2009

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
- 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.

- 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


More information about the FreeTDS mailing list