Skip to content
Snippets Groups Projects
Commit c8a01666 authored by Charles Munger's avatar Charles Munger
Browse files

Simplify query for tables_used; no need to count when we only care if there's one.

Change-Id: I63c9f4a057b7f470c9f44be6f73e61e1cb31f3c6
parent 0bf06c23
No related branches found
No related tags found
No related merge requests found
......@@ -436,7 +436,7 @@ static jboolean nativeUpdatesTempOnly(JNIEnv* env, jclass,
int result = SQLITE_OK;
if (connection->tableQuery == nullptr) {
static char const* sql =
"SELECT COUNT(*) FROM tables_used(?) WHERE schema != 'temp' AND wr != 0";
"SELECT NULL FROM tables_used(?) WHERE schema != 'temp' AND wr != 0";
result = sqlite3_prepare_v2(connection->db, sql, -1, &connection->tableQuery, nullptr);
if (result != SQLITE_OK) {
ALOGE("failed to compile query table: %s",
......@@ -455,17 +455,14 @@ static jboolean nativeUpdatesTempOnly(JNIEnv* env, jclass,
return false;
}
result = sqlite3_step(query);
if (result != SQLITE_ROW) {
// Make sure the query is no longer bound to the statement SQL string.
sqlite3_clear_bindings(query);
if (result != SQLITE_ROW && result != SQLITE_DONE) {
ALOGE("tables query error: %d/%s", result, sqlite3_errstr(result));
// Make sure the query is no longer bound to the statement.
sqlite3_clear_bindings(query);
return false;
}
int count = sqlite3_column_int(query, 0);
// Make sure the query is no longer bound to the statement SQL string.
sqlite3_clear_bindings(query);
return count == 0;
return result == SQLITE_DONE;
}
static jint nativeGetColumnCount(JNIEnv* env, jclass clazz, jlong connectionPtr,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment