[Home]

Summary:ASTERISK-10605: cdr_sqlite3_custom backend error when logging to db
Reporter:Warren Volz (wvolz)Labels:
Date Opened:2007-10-23 15:24:03Date Closed:2007-12-06 15:55:19.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:CDR/cdr_sqlite3_custom
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) cdr_sqlite3_custom.c.2.patch
( 1) cdr_sqlite3_custom.c.3.patch
Description:Every time the cdr_sqlite3_custom log function is called I see errors in my messages log that look like the following:

[Oct 23 14:35:55] ERROR[4552]: cdr_sqlite3_custom.c:180 sqlite3_log: cdr_sqlite3_custom: unrecognized token: "081d81d8". sentence: INSERT INTO cdr (calldate, clid, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, amaflags, accountcode, uniqueid, userfield, test) VALUES (''''2007-10-23 14:35:53'''',''''"Cisco 7960-1" <1001>'''',''''localports'''',''''SIP/cisco-7960-1-081d81d8'''','''''''',''''VoiceMailMain'''','''''''',''''2'''',''''2'''',''''ANSWERED'''',''''DOCUMENTATION'''','''''''',''''1193171753.0'''','''''''','''''''').

I've gone back and changed the schema thinking that was related, but even with the default settings and created schema I see this error. The other sqlite backends work correctly.
Comments:By: Warren Volz (wvolz) 2007-10-23 15:26:56

System/library versions:

sqlite3 v3.3.8
debian 4.0 2.6.18-5

By: Jason Parker (jparker) 2007-10-23 15:37:52

This appears to be due to the quotes in your CallerID.  Please try removing them.

By: Warren Volz (wvolz) 2007-10-23 18:36:32

Removed quotes, still seeing issue:

[Oct 23 17:53:35] ERROR[2174]: cdr_sqlite3_custom.c:180 sqlite3_log: cdr_sqlite3_custom: unrecognized token: "081eb0b8". sentence: INSERT INTO cdr (calldate, clid, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, amaflags, accountcode, uniqueid, userfield, test) VALUES (''''2007-10-23 17:53:26'''',''''anonymous'''',''''sip-incoming'''',''''SIP/17476199990-081eb0b8'''',''''Zap/2-1'''',''''Dial'''',''''Zap/2&Sip/cisco-7960-1,20|t'''',''''9'''',''''0'''',''''NO ANSWER'''',''''DOCUMENTATION'''','''''''',''''1193183606.0'''','''''''','''''''').

By: Warren Volz (wvolz) 2007-10-23 18:42:52

Even with the quotes, shouldn't the module be smart enough to handle those? There are examples in the sip.conf file that have quotes in the exact same place.

By: Jason Parker (jparker) 2007-10-29 16:35:13

I still suspect that this has something to do with quotes.  Do you have quotes in your values column?  There appear to be an extra set on every one of them.

And yes, it probably should account for quotes.

By: Warren Volz (wvolz) 2007-10-29 18:43:08

I'm using the default config file from the version I checked out of SVN. If I remove the quotes from the values column I get the following error:

[Oct 29 16:43:43] ERROR[9021] cdr_sqlite3_custom.c: cdr_sqlite3_custom: near "16": syntax error. sentence: INSERT INTO cdr (calldate, clid, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, amaflags, accountcode, uniqueid, userfield, test) VALUES (2007-10-29 16:43:41,"Cisco 7960-1" <1001>,localports,SIP/cisco-7960-1-b7a6d900,,VoiceMailMain,,2,2,ANSWERED,DOCUMENTATION,,1193697821.23,,).

By: Sean Bright (seanbright) 2007-11-04 11:36:55.000-0600

Uploaded a patch.  I'm not a huge fan of my changes, but it works during my local tests.  The module still needs some work, but this should work for now.  Give it a shot and let me know if you have any problems.



By: Sean Bright (seanbright) 2007-11-04 12:31:23.000-0600

New patch that won't crash when you unload the module.  (woops)

By: Jason Parker (jparker) 2007-11-05 15:04:00.000-0600

This looks far better than it did before.  Escaping the individual columns is definitely the way to go.

By: Jason Parker (jparker) 2007-11-07 14:26:53.000-0600

wvolz, any luck with testing this?

By: Warren Volz (wvolz) 2007-11-19 17:43:45.000-0600

Sorry for the delay. The second patch works for me, however it did not apply cleanly to SVN 89433.

By: Sean Bright (seanbright) 2007-12-04 13:43:36.000-0600

Updated patch (cdr_sqlite3_custom.c.3.patch) which should apply cleanly against trunk.  Also took care of some lock contention and memory deallocation in the event of failure to load the configuration.

By: Digium Subversion (svnbot) 2007-12-06 15:55:19.000-0600

Repository: asterisk
Revision: 91598

U   trunk/cdr/cdr_sqlite3_custom.c

------------------------------------------------------------------------
r91598 | qwell | 2007-12-06 15:55:18 -0600 (Thu, 06 Dec 2007) | 4 lines

Fix a problem with quoting in sqlite3 cdr module..

Closes issue ASTERISK-10605, patch by seanbright.

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=91598