From e3275cf188c85ccb3b73b73c18d60bef87593c1a Mon Sep 17 00:00:00 2001 From: Mike Lin Date: Sat, 13 Jan 2024 11:38:33 -1000 Subject: [PATCH] make immutable=1 imply SQLITE_OPEN_READONLY --- src/SQLiteNestedVFS.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SQLiteNestedVFS.h b/src/SQLiteNestedVFS.h index 38a37c2..d256de7 100644 --- a/src/SQLiteNestedVFS.h +++ b/src/SQLiteNestedVFS.h @@ -1005,6 +1005,7 @@ class InnerDatabaseFile : public SQLiteVFS::File { } } catch (SQLite::Exception &exn) { SQLITE_NVFS_LOG(1, exn.what()) + SQLiteVFS::File::Close(); // deletes this return exn.getErrorCode(); } unsigned long long sequential = 0, non_sequential = 0, interior_hits = 0; @@ -1027,7 +1028,7 @@ class InnerDatabaseFile : public SQLiteVFS::File { << "ms decode: " << t_decode.count() / 1000000 << "ms") } SQLITE_NVFS_LOG(3, "xClose") - return SQLiteVFS::File::Close(); + return SQLiteVFS::File::Close(); // deletes this } int ShmMap(int iPg, int pgsz, int isWrite, void volatile **pp) override { @@ -1222,6 +1223,7 @@ class VFS : public SQLiteVFS::Wrapper { outer_db_uri += "?nolock=1&psow=1"; } else if (sqlite3_uri_boolean(zName, "immutable", 0)) { outer_db_uri += "?immutable=1"; + flags |= SQLITE_OPEN_READONLY; } if (log_filename_.rfind('/') != std::string::npos) { log_filename_ = log_filename_.substr(log_filename_.rfind('/') + 1);