Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c2d397b authored by Lee Shombert's avatar Lee Shombert
Browse files

Improve temp-table query

The method that checks for the use of temporary tables cleans its
statement before it runs the query.  This leaves the statement in a
"dirty" state between checks, which locks the tables_used table.  This
change cleans the statement after the query is run so that no locks
are held.

The unit test has been updated.

Flag: EXEMPT bugfix
Bug: 342497314
Test: atest
 * CtsDatabaseTestCases
 * FrameworksCoreTests:android.database
Change-Id: I54032d8c360b123596ca73e6c294dbb285e05361
parent d6004db9
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -447,20 +447,18 @@ static jboolean nativeUpdatesTempOnly(JNIEnv* env, jclass,

    // A temporary, to simplify the code.
    sqlite3_stmt* query = connection->tableQuery;
    sqlite3_reset(query);
    sqlite3_clear_bindings(query);
    result = sqlite3_bind_text(query, 1, sqlite3_sql(statement), -1, SQLITE_STATIC);
    if (result != SQLITE_OK) {
        ALOGE("tables bind pointer returns %s", sqlite3_errstr(result));
        return false;
    }
    result = sqlite3_step(query);
    // Make sure the query is no longer bound to the statement SQL string.
    // Make sure the query is no longer bound to the statement SQL string and
    // that is no longer holding any table locks.
    sqlite3_reset(query);
    sqlite3_clear_bindings(query);

    if (result != SQLITE_ROW && result != SQLITE_DONE) {
        ALOGE("tables query error: %d/%s", result, sqlite3_errstr(result));
        return false;
    }
    return result == SQLITE_DONE;
}
+2 −0
Original line number Diff line number Diff line
@@ -375,6 +375,8 @@ public class SQLiteDatabaseTest {
                assertEquals(3, s.getColumnInt(0));
            }

            mDatabase.execSQL("DROP TABLE t1");

        } catch (SQLiteException e) {
            allowed = false;
        } finally {