[egenix-users] Null termination differences in drivers - comment
in mxODBC.c
M.-A. Lemburg
mal at egenix.com
Fri Oct 22 16:49:29 CEST 2004
Martin J. Evans wrote:
> Could anyone explain the origin of the following comment in mxODBC.c
> (specifically the reference to the Easysoft Oracle driver)?
We had to add that work-around to make mxODBC work with the
EasySoft Oracle driver 1.0.0.6. Things may be different with
more recent versions. The work-around adapts accordingly.
> How do you reproduce this?
Simple: query a BLOB of say 1MB data from the database.
> Thanks.
>
> if (null_terminated) {
> /* Remove null termination; various ODBC drivers have bugs
> in the way the handle null-termination:
>
> * EasySoft ODBC for Oracle does not null-terminate character
> columns, even though it should
>
> * MS SQL Server ODBC always null-terminates Unicode columns
> with two nulls, even when fetching the data as SQL_C_CHAR
> where it should only append one null-termination character
>
> The ODBC standard is unclear about what to do, but
> using sizeof(SQLWCHAR) seems to work in most
> cases. We have to careful here, since some database
> drivers allow passing binary data back through
> character columns, so embedded nulls are well
> possible.
>
> Thanks to Tommi Auvinen for helping to track down
> the MS SQL Server problem.
>
> */
> char *data = (char *)newdata;
> int endofdata = offset + received - 1;
> if (data[endofdata] == '\0') {
> received--;
> #ifdef SQL_WCHAR
> if (data[endofdata - 1] == '\0') {
> if (var->ctype == SQL_C_WCHAR ||
> var->sqltype == SQL_WCHAR ||
> var->sqltype == SQL_WVARCHAR ||
> var->sqltype == SQL_WLONGVARCHAR)
> received -= sizeof(SQLWCHAR) - 1;
> }
> #endif
> }
> }
>
>
> --
> Martin J. Evans
> Easysoft Ltd, UK
> Development
>
>
> _______________________________________________________________________
> eGenix.com User Mailing List http://www.egenix.com/
> http://lists.egenix.com/mailman/listinfo/egenix-users
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Oct 22 2004)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the egenix-users
mailing list