[Asterisk-Dev] Re: cdr_odbc and SQLite

David Creemer david at zachary.com
Thu Jun 17 01:32:50 MST 2004


Following up on my own post:

On Jun 16, 2004, at 1:27 PM, David Creemer wrote:

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

included is a patch to cdr_odbc.c that fixes this problem. I have 
confirmed that it works with SQLite and PostgreSQL.

-- David

-------------- next part --------------
A non-text attachment was scrubbed...
Name: asterisk-cdr_odbc-update.patch
Type: application/octet-stream
Size: 3190 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20040617/22e14cc8/asterisk-cdr_odbc-update.obj
-------------- next part --------------



More information about the asterisk-dev mailing list