Build Android version with -DSQLITE_TEMP_STORE=3

Issue #76 resolved
Former user created an issue

Originally reported on Google Code with ID 76

While attempting to integrate sqlite4java with my Cordova sqlite adapter project, I
encountered an issue with certain UPDATE statements which will be fixed by adding -DSQLITE_TEMP_STORE=3
to LOCAL_CFLAGS in ant/ In addition, I see no need for the following
option (and verified using grep): -DTEMP_STORE=1

The following test code reproduces the issue and verifies the fix on Android:

  SQLiteConnection connection = database; // given by the test framework

  try {;

    connection.exec("begin immediate");

    SQLiteStatement st1 = connection.prepare("DROP TABLE IF EXISTS Task");

    SQLiteStatement st2 = connection.prepare("CREATE TABLE IF NOT EXISTS Task (id primary
key, subject)");

    SQLiteStatement st3 = connection.prepare("INSERT INTO Task VALUES ('928238b3-a227-418f-aa15-12bb1943c1f2','test1')");

    SQLiteStatement st4 = connection.prepare("INSERT INTO Task VALUES ('511e3fb7-5aed-4c1a-b1b7-96bf9c5012e2',

  } catch(Exception e) {
    Log.e("SQLiteUpdateTest", "errr", e);
    return false;

  try {
    long lastTotal1 = connection.getTotalChanges();
    Log.v("SQLiteUpdateTest", "lastTotal1: " + lastTotal1);
    SQLiteStatement st5 = connection.prepare("UPDATE Task SET subject='Send reminder',
id='928238b3-a227-418f-aa15-12bb1943c1f2' WHERE id = '928238b3-a227-418f-aa15-12bb1943c1f2'");
    Log.v("SQLiteUpdateTest", "next statement prepared");
    boolean hasRows1 = st5.step();
    long newTotal1 = connection.getTotalChanges();
    Log.v("SQLiteUpdateTest", "newTotal1: " + newTotal1);
    Log.v("SQLiteUpdateTest", "finished");
    return (lastTotal1+1 == newTotal1);

  } catch(Exception e) {
    Log.e("SQLiteUpdateTest", "errr", e);
    return false;

Here is the proposed change to ant/

--- ant/ (revision 399)
+++ ant/ (working copy)
@@ -20,6 +20,6 @@
 LOCAL_MODULE       := sqlite4java-android
 LOCAL_SRC_FILES    := $(BASE)/sqlite/sqlite3.c $(BASE)/build/swig/sqlite_wrap.c $(BASE)/native/sqlite3_wrap_manual.c
-LOCAL_CFLAGS       := -O2 -DNDEBUG -Dfdatasync=fsync -fno-omit-frame-pointer -fno-strict-aliasing
-static-libgcc -I../../../sqlite -I../../../native -DSQLITE_ENABLE_COLUMN_METADATA
+LOCAL_CFLAGS       := -O2 -DNDEBUG -Dfdatasync=fsync -fno-omit-frame-pointer -fno-strict-aliasing
-static-libgcc -I../../../sqlite -I../../../native -DSQLITE_ENABLE_COLUMN_METADATA

Reported by Chris.Brody on 2015-04-08 16:49:21

Comments (6)

  1. Former user Account Deleted
    Hi Chris,
    Thanks for providing a test and a patch. (By the way, you can replace "conn.prepare(),
    st.step(); st.dispose();" with "conn.exec()" if you don't have any parameters.)
    I wonder how this parameter affects this test. Did you dig into the details?
    Kind regards,

    Reported by on 2015-04-16 23:19:23

  2. Former user Account Deleted
    Hi Igor,
    Unfortunately I only dug deep enough to figure out what kind of error was reported
    by sqlite3.c. I noticed that both
    and are using -DSQLITE_TEMP_STORE=3
    I cannot promise when I will get a chance to dig for a deeper explanation.
    Also, I highly recommend we consider getting rid of -DTEMP_STORE=1 since it has no
    meaning and can become a bit confusing.

    Reported by Chris.Brody on 2015-04-20 18:19:02

  3. Former user Account Deleted
    P.S. Agreed it is better to use conn.exec() since my test is not using any parameters.

    Reported by Chris.Brody on 2015-04-20 18:20:03

  4. Former user Account Deleted
    Chris, thanks for your input - will do!

    Reported by on 2015-04-26 22:40:11 - Status changed: Accepted

  5. Log in to comment