Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
NotificationsYou must be signed in to change notification settings

Dimezis/WALtest

Repository files navigation

When performing a query onSQLiteDatabase, theSQLiteProgram fromandroid.database.sqlite performsSQLiteStatementType.getSqlStatementType(mSql) check to guess the query type and to prepare a SQL statement for execution.See -https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/database/sqlite/SQLiteProgram.java;l=60-64;drc=ee976fd24cfbd567c4543da39aadb1b3e4567042

This query type guessing is very basic and naive, relying on the first 3 letters of the SQL statement -https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/database/DatabaseUtils.java;drc=ee976fd24cfbd567c4543da39aadb1b3e4567042;l=1566

So for example, if the query is a Select query, but contains a comment like this:

   -- comment   select * from employees limit 1;

It will NOT be recognized as a Select query andassumeReadOnly will be false.

Most of the time it doesn't matter, but with WAL mode enabled, we expect the SQLite to be able to perform read queries during writing, but thisassumeReadOnly breaks this behavior.

See the sample code that demonstrates the issuehttps://github.com/Dimezis/WALtest/blob/master/app/src/main/java/com/example/waltest/MainActivity.kt.Pay attention tofastReadQuery method and its comment.

This app performs basic insert transactions on 1 writer thread, and reads withselect on the other thread with DB in WAL mode.If you remove the comment-- comment from the query, you can see that the reading is done concurrently according to logs and their timestamps:

  • WAL write start
  • WAL read start
  • WAL read end
  • WAL write end

If you leave the-- comment though, concurrent reading doesn't work anymore and the output is:

  • WAL write start
  • WAL read start
  • WAL write end
  • WAL read end

https://issuetracker.google.com/issues/270105918

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp