Summary:ASTERISK-07587: [patch] res_sqlite module for Asterisk - SQLite 2 support
Reporter:Richard Braun (rbraun_proformatique)Labels:
Date Opened:2006-08-23 08:59:15Date Closed:2007-03-13 16:30:12
Versions:Frequency of
Environment:Attachments:( 0) Doxyfile
( 1) extconfig.conf
( 2) extensions.conf
( 3) Makefile
( 5) res_sqlite.c
( 6) res_sqlite.conf
( 7) tables.sql

Yes, I know, there already is a res_sqlite3 module in the addons :-). But SQLite 2 is used here and I needed full RealTime support. So here is a little res_sqlite module that does it all. It can be used for CDR logging, static/RealTime configuration, and a MYSQL()-like command for the Dialplan. Could it make it into the Asterisk addons ?

Here is the source code :

A disclaimer has been faxed to Digium (using the name "Proformatique" instead of mine, as the module is the intellectual property of the Proformatique company).

Thanks for any review.
Comments:By: Serge Vecher (serge-v) 2006-08-23 09:49:46

rbraun: please attach the patches in uncompressed format directly to this bug-note. Thank you.

By: Serge Vecher (serge-v) 2006-08-23 09:50:31

probably better rename it res_sqlite2 to follow convention too...

By: Richard Braun (rbraun_proformatique) 2006-08-23 09:59:21

AIUI, software related to SQLite 2 have no version number appended, whereas software related to SQLite 3 usually have "3" in their name. At least, this is true for libsqlite{,3}.so, and the already existing module in the addons is named res_sqlite3, so...

By: Richard Braun (rbraun_proformatique) 2006-08-23 10:01:13

In addition, res_sqlite is not a patch, it's a module of more than 2 thousand lines and full documentation. Are you sure you want me to attach it here ?

By: Serge Vecher (serge-v) 2006-08-23 10:06:10

yes, at least the res_sqlite.c, makefile and *.conf file. Thanks.

By: Richard Braun (rbraun_proformatique) 2006-08-23 10:27:32

Here you are. BTW, do the code guidelines also apply to modules not directly included in Asterisk ?

By: Serge Vecher (serge-v) 2006-08-23 10:34:30

yes, they do...

By: Richard Braun (rbraun_proformatique) 2006-08-23 10:42:52

Ah. I guess this prevents res_sqlite from making it into the addons (I must admit I didn't think about sending the code here until recently, so the code doesn't follow the guidelines). How do you want this issue to be solved then ?

By: Serge Vecher (serge-v) 2006-08-23 11:02:56

hmmm: quick answer -- change formatting to conform... But let's get some architectural feedback first. The big question with code going to asterisk-addons is maintainability ... But then, you have disclaimed this code, so theoretically it could go into the main trunk.

By: jmls (jmls) 2006-10-31 12:13:33.000-0600

did we get any architectural feedback ?

By: Richard Braun (rbraun_proformatique) 2006-11-03 04:28:09.000-0600

I didn't get any...

By: Anthony LaMantia (alamantia) 2006-11-03 10:43:53.000-0600

from what is being discussed in 6754.. i am thinking that just moving the cdr sqlite support to version 3 only is the general way to go

sqlite3 is able to read sqlite2 and 1 databases.  and is not a hefty package to upgrade at all.  

i really see that adding support for each old version of sqlite and all of the api changes in asterisk would lead to a collection of cdr_sqlite*.c files or a giant messy cdr_sqlite.c full of ugly ifdefs all over.

what are your thoughts on this?

By: jmls (jmls) 2006-11-03 10:46:39.000-0600

if what you say is true, I would say we should standardise on sqlite3

By: Richard Braun (rbraun_proformatique) 2006-11-03 10:59:46.000-0600

From http://www.sqlite.org/version3.html :

``New File Format

The format used by SQLite database files has been completely revised. The old version 2.1 format and the new 3.0 format are incompatible with one another. Version 2.8 of SQLite will not read a version 3.0 database files and version 3.0 of SQLite will not read a version 2.8 database file.''

I may be mistaken but I don't remember anything stating that SQLite 3 could use SQLite 2 databases...

By: Anthony LaMantia (alamantia) 2006-11-03 11:44:37.000-0600

Ah, i see.. i guess that it's some what backwards compatable..
you should still be able to dump the database and import it into the latest format somewhat easily.

By: Richard Braun (rbraun_proformatique) 2006-11-03 12:04:43.000-0600

I'll explain our problem a bit. We're developing a user interface in PHP 4 that will process a SQLite database used with the Asterisk realtime architecture. This means that the same database will be simultaneously used by Asterisk and PHP. And currently, PHP 4 has no stable support for SQLite 3. So we simply can't upgrade the format of the database...

And all this will be running in an embedded environment, which means we need stability, old robust stuff, etc... So we chose to include good SQLite 2 support in Asterisk, and use the SQLite 2 support in PHP, which currently works flawlessly for us.

All of this to say that some people really need SQLite 2. If you simply don't want SQLite 2 support, don't include it in the Asterisk source tree, I would be fine with that.

By: Anthony LaMantia (alamantia) 2006-11-03 13:50:27.000-0600

ah, i see.. well maybe then the keeping one res_sqlite.c with some ifdef and autoconf magic is the solution.. personally i just want to avoid having to have several res_sqlite files...

By: Russell Bryant (russell) 2007-03-13 16:30:11

This module has been merged into the trunk in revision 58866.  However, I went through the file and changed a lot to match our formatting guidelines and may have broken something.  So, please test it again when you have the chance.

Also, I removed the application from this code because this is something that if added, should be made a dialplan function, instead.  Consider how func_odbc is written for an example.

Thank you very much for your contribution!