backend_firefox: don't bother opening db readonly

Readonly db does not work well with WAL mode.
See <https://www.sqlite.org/wal.html#readonly>.
This commit is contained in:
CismonX 2025-01-14 19:44:34 +08:00
parent 76d22c5bcc
commit 349877f9a3
No known key found for this signature in database
GPG key ID: 3094873E29A482FB
3 changed files with 8 additions and 17 deletions

View file

@ -2683,7 +2683,7 @@ backend_create (
return -1; return -1;
} }
sqlite3 *db = db_open(conf->store_path, readonly); sqlite3 *db = db_open(conf->store_path);
if (db == NULL) { if (db == NULL) {
return -1; return -1;
} }
@ -3150,7 +3150,7 @@ backend_mkfs (
// See also: // See also:
// - <https://sqlite.org/forum/forumpost/c15bf2e7df289a5f> // - <https://sqlite.org/forum/forumpost/c15bf2e7df289a5f>
// - <https://sqlite.org/forum/forumpost/680cd395b4bc97c6> // - <https://sqlite.org/forum/forumpost/680cd395b4bc97c6>
sqlite3 *db = db_open(conf->store_path, false); sqlite3 *db = db_open(conf->store_path);
if (db == NULL) { if (db == NULL) {
goto end; goto end;
} }

View file

@ -214,26 +214,18 @@ db_fcntl (
sqlite3 * sqlite3 *
db_open ( db_open (
char const *path, char const *path
bool readonly
) { ) {
sqlite3 *db; sqlite3 *db;
int flags = SQLITE_OPEN_READWRITE; int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_EXRESCODE;
if (readonly) {
flags = SQLITE_OPEN_READONLY;
}
flags |= SQLITE_OPEN_EXRESCODE;
if (SQLITE_OK != sqlite3_open_v2(path, &db, flags, NULL)) { if (SQLITE_OK != sqlite3_open_v2(path, &db, flags, NULL)) {
log_printf("sqlite3_open_v2(): %s", sqlite3_errmsg(db)); log_printf("sqlite3_open_v2(): %s", sqlite3_errmsg(db));
goto fail; goto fail;
} }
if (!readonly) { if (0 != sqlite3_db_readonly(db, "main")) {
if (0 != sqlite3_db_readonly(db, "main")) { log_puts("cannot open database for read/write");
log_puts("cannot open database for read/write"); goto fail;
goto fail;
}
} }
return db; return db;
fail: fail:

View file

@ -113,8 +113,7 @@ db_fcntl (
sqlite3 * sqlite3 *
db_open ( db_open (
char const *path, char const *path
bool readonly
); );
int int