From b2bcb19b22abc9613979ba2ab445c33b940ce616 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Wed, 21 Aug 2024 12:33:43 -0700 Subject: [PATCH] SQLite: Add pragma integrity_check --- src/storage/backend/sqlite/SQLite.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/storage/backend/sqlite/SQLite.cc b/src/storage/backend/sqlite/SQLite.cc index e166e861c8..db43201a1d 100644 --- a/src/storage/backend/sqlite/SQLite.cc +++ b/src/storage/backend/sqlite/SQLite.cc @@ -53,6 +53,14 @@ ErrorResult SQLite::DoOpen(RecordValPtr options) { return err; } + if ( int res = sqlite3_exec(db, "pragma integrity_check", NULL, NULL, &errorMsg); res != SQLITE_OK ) { + std::string err = util::fmt("Error executing integrity check: %s", errorMsg); + Error(err.c_str()); + sqlite3_free(errorMsg); + Close(); + return err; + } + auto tuning_params = options->GetField("tuning_params")->ToMap(); for ( const auto& [k, v] : tuning_params ) { auto ks = k->AsListVal()->Idx(0)->AsStringVal();