Skip to content

Commit 1c0e815

Browse files
Adding support for issuing a sqlite3_status call
1 parent 7710fab commit 1c0e815

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

jni/net_sqlcipher_database_SQLiteDatabase.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ static void registerLoggingFunc(const char *path) {
9292
loggingFuncSet = true;
9393
}
9494

95+
int native_status(JNIEnv* env, jobject object, jint operation, jboolean reset)
96+
{
97+
int value;
98+
int highWater;
99+
sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle);
100+
int status = sqlite3_status(operation, &value, &highWater, reset);
101+
if(status != SQLITE_OK){
102+
throw_sqlite3_exception(env, handle);
103+
}
104+
return value;
105+
}
106+
95107
void native_rawExecSQL(JNIEnv* env, jobject object, jstring sql)
96108
{
97109
sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle);
@@ -479,6 +491,7 @@ static JNINativeMethod sMethods[] =
479491
{"releaseMemory", "()I", (void *)native_releaseMemory},
480492
{"setICURoot", "(Ljava/lang/String;)V", (void *)setICURoot},
481493
{"native_rawExecSQL", "(Ljava/lang/String;)V", (void *)native_rawExecSQL},
494+
{"native_status", "(IZ)I", (void *)native_status},
482495
};
483496

484497
int register_android_database_SQLiteDatabase(JNIEnv *env)

src/net/sqlcipher/database/SQLiteDatabase.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ public class SQLiteDatabase extends SQLiteClosable {
7373
private static final int EVENT_DB_OPERATION = 52000;
7474
private static final int EVENT_DB_CORRUPT = 75004;
7575

76+
public int status(int operation, boolean reset){
77+
return native_status(operation, reset);
78+
}
79+
7680
public static void upgradeDatabaseFormatFromVersion1To2(File databaseToMigrate, String password) throws Exception {
7781

7882
File newDatabasePath = null;
@@ -2430,4 +2434,6 @@ private static ArrayList<Pair<String, String>> getAttachedDbs(SQLiteDatabase dbO
24302434
private native int native_getDbLookaside();
24312435

24322436
private native void native_rawExecSQL(String sql);
2437+
2438+
private native int native_status(int operation, boolean reset);
24332439
}

0 commit comments

Comments
 (0)