[egenix-users]
Null termination differences in drivers - comment in mxODBC.c
Martin J. Evans
martin.evans at easysoft.com
Fri Oct 22 15:28:20 CEST 2004
Could anyone explain the origin of the following comment in mxODBC.c
(specifically the reference to the Easysoft Oracle driver)?
How do you reproduce this?
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
More information about the egenix-users
mailing list