[Asterisk-Dev] cdr_odbc and SQLite
David Creemer
david at zachary.com
Wed Jun 16 13:27:04 MST 2004
Hi-
I've been looking at cdr_odbc.c (lastest * CVS HEAD). I've tried
binding to a SQLite DB, with some errant behavior -- character string
do not make it into the database (but integers do). I installed
unixODBC from latest source, and have verified that I can connect to
and read/write to my data source using for example python-odbc.
In looking at the cdr_odbc.c source, I notice that calls to
SQLBindParameter look like this:
SQLBindParameter(ODBC_stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR, sizeof(cdr->clid), 0, cdr->clid, 0, NULL);
I've looked at some of the sample ODBC drivers in the unixODBC package
and this doesn't seem correct. See the txt driver for example.
The following seems to work with txt and SQLite backends:
SQLLEN flen = 80;
SQLBindParameter(ODBC_stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR, sizeof(cdr->clid), 0, cdr->clid, sizeof(cdr->clid), &flen);
It seems that at least some ODBC drivers interpret the final field as
the actual length of the data, and the second to last field as the size
of the passed in field buffer.
I also think that sizeof( X ) only works as intended above if X is
defined a char X[80], not if X is "char *X = (char*)malloc(80)". I
haven't checked all of the cdr-> fields to be sure they meet that
restriction.
Is my analysis here correct? If so (sorry for newbie question) should I
just file a bug?
regards,
-- David
More information about the asterisk-dev
mailing list