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

View file

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

View file

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