Re: FreeTDS always setting empty VARCHAR's to NULL
Frediano Ziglio <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
2009/6/23 Andrew Victor <[email protected]>: > 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 _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds