mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-06-07 19:58:50 +00:00
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:
parent
76d22c5bcc
commit
349877f9a3
3 changed files with 8 additions and 17 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
18
src/db.c
18
src/db.c
|
@ -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:
|
||||||
|
|
3
src/db.h
3
src/db.h
|
@ -113,8 +113,7 @@ db_fcntl (
|
||||||
|
|
||||||
sqlite3 *
|
sqlite3 *
|
||||||
db_open (
|
db_open (
|
||||||
char const *path,
|
char const *path
|
||||||
bool readonly
|
|
||||||
);
|
);
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Add table
Reference in a new issue