mirror of
https://github.com/NixOS/nix.git
synced 2025-11-12 21:46:01 +01:00
Open sqlite database according to new modes.
This commit is contained in:
parent
afed9ccfad
commit
78fdd6f24e
3 changed files with 13 additions and 5 deletions
|
|
@ -50,14 +50,15 @@ static void traceSQL(void * x, const char * sql)
|
|||
notice("SQL<[%1%]>", sql);
|
||||
};
|
||||
|
||||
SQLite::SQLite(const Path & path, bool create)
|
||||
SQLite::SQLite(const Path & path, SQLiteOpenMode mode)
|
||||
{
|
||||
// useSQLiteWAL also indicates what virtual file system we need. Using
|
||||
// `unix-dotfile` is needed on NFS file systems and on Windows' Subsystem
|
||||
// for Linux (WSL) where useSQLiteWAL should be false by default.
|
||||
const char *vfs = settings.useSQLiteWAL ? 0 : "unix-dotfile";
|
||||
int flags = SQLITE_OPEN_READWRITE;
|
||||
if (create) flags |= SQLITE_OPEN_CREATE;
|
||||
int flags = mode == SQLiteOpenMode::ReadOnly
|
||||
? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE;
|
||||
if (mode == SQLiteOpenMode::Normal) flags |= SQLITE_OPEN_CREATE;
|
||||
int ret = sqlite3_open_v2(path.c_str(), &db, flags, vfs);
|
||||
if (ret != SQLITE_OK) {
|
||||
const char * err = sqlite3_errstr(ret);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue