[PATCH] sqlite3_prepare_v2 for pre 3.3.9 versions

Stipe Tolj <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Organization tolj.org system architecture
Message-ID <[email protected]>
Hi all,

we have a problem with the latest enhancements in the gwlib/dbpool_sqlite3.c 
commit. The function sqlite3_prepare_v2() is available since 3.3.9, according to 
URL:

   http://www.sqlite.org/oldnews.html

But, we DO use the function 2x without really checking which sqlite3 version 
we're using. The patch handles this via a simple #if case.

Normally, I would suggest to handle this at configure time, and simply inform 
the user to use a sqlite3 version >= 3.3.9. But, some of the major used distros, 
i.e. CentOS 5.x uses an rather old sqlite3 in the distro repository, and I tend 
to have them supported out of the box, rather then forcing the users to upgrade 
the sqlite3 from source.

Comments please.

Stipe

-- 
-------------------------------------------------------------------
Kölner Landstrasse 419
40589 Düsseldorf, NRW, Germany

tolj.org system architecture      Kannel Software Foundation (KSF)
http://www.tolj.org/              http://www.kannel.org/

mailto:st_{at}_tolj.org           mailto:stolj_{at}_kannel.org
-------------------------------------------------------------------
sqlite3_prepare_v2.diff (text/plain, 1 KB)
Index: gwlib/dbpool_sqlite3.c
===================================================================
--- gwlib/dbpool_sqlite3.c	(revision 4890)
+++ gwlib/dbpool_sqlite3.c	(working copy)
@@ -147,7 +147,11 @@
     *res = NULL;
 
     /* prepare statement */
+#if SQLITE_VERSION_NUMBER >= 3003009    
     status = sqlite3_prepare_v2(db, octstr_get_cstr(sql), octstr_len(sql) + 1, &stmt, &rem);
+#else    
+    status = sqlite3_prepare(db, octstr_get_cstr(sql), octstr_len(sql) + 1, &stmt, &rem);
+#endif
     if (SQLITE_OK != status) {
         error(0, "SQLite3: %s", sqlite3_errmsg(db));
         return -1;
@@ -209,7 +213,11 @@
     int binds_len = (binds ? gwlist_len(binds) : 0);
 
     /* prepare statement */
+#if SQLITE_VERSION_NUMBER >= 3003009    
     status = sqlite3_prepare_v2(db, octstr_get_cstr(sql), octstr_len(sql) + 1, &stmt, &rem);
+#else
+    status = sqlite3_prepare(db, octstr_get_cstr(sql), octstr_len(sql) + 1, &stmt, &rem);
+#endif    
     if (SQLITE_OK != status) {
         error(0, "SQLite3: %s", sqlite3_errmsg(db));
         return -1;
smime.p7s (application/pkcs7-signature, 5.8 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.