Skip to content

Conversation

@brody4hire
Copy link

Added to native SQLiteDatabase.dbopen() & SQLiteDatabase.setLocale() functions (C++)
Needed to help diagnose exceptions in #139 & #161
Extra minor cleanup of includes

Some credit is due to: https://github.com/android/platform_frameworks_base/blob/master/core/jni/android_database_SQLiteConnection.cpp

NOTE: The first time I tested these changes (on my Motorola Moto G), the Multi-threaded read/write test caused a crash with a fatal exception:

E/AndroidRuntime( 6187): FATAL EXCEPTION: Thread-41325
E/AndroidRuntime( 6187): Process: net.zetetic, PID: 6187
E/AndroidRuntime( 6187): net.sqlcipher.database.SQLiteMisuseException: library routine called out of sequence: , while compiling: select count(*) from t1;
E/AndroidRuntime( 6187):    at net.sqlcipher.database.SQLiteCompiledSql.native_compile(Native Method)
E/AndroidRuntime( 6187):    at net.sqlcipher.database.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
E/AndroidRuntime( 6187):    at net.sqlcipher.database.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
E/AndroidRuntime( 6187):    at net.sqlcipher.database.SQLiteProgram.<init>(SQLiteProgram.java:103)
E/AndroidRuntime( 6187):    at net.sqlcipher.database.SQLiteQuery.<init>(SQLiteQuery.java:49)
E/AndroidRuntime( 6187):    at net.sqlcipher.database.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
E/AndroidRuntime( 6187):    at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1447)
E/AndroidRuntime( 6187):    at net.sqlcipher.database.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1416)
E/AndroidRuntime( 6187):    at net.zetetic.tests.MultiThreadReadWriteTest$Reader.getCurrentTableCount(MultiThreadReadWriteTest.java:118)
E/AndroidRuntime( 6187):    at net.zetetic.tests.MultiThreadReadWriteTest$Reader.run(MultiThreadReadWriteTest.java:94)
E/AndroidRuntime( 6187):    at java.lang.Thread.run(Thread.java:818)
W/ActivityManager(  946):   Force finishing activity net.zetetic/.TestSuiteActivity

When I tested again it passed the full test suite. I am suspicious that there is a transient condition that is not directly related to my changes. I will put the log in a comment and then try to investigate this one.

@developernotes
Copy link
Member

@brodybits - this is a great change, it should certainly help trace out where potential errors occurred. Thanks!

@brody4hire brody4hire deleted the native-db-error-check branch January 12, 2021 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants