From 0ece395c24384a33cd143e445da168c468acf5f4 Mon Sep 17 00:00:00 2001 From: Vlad <129996061+vvysokikh1@users.noreply.github.com> Date: Fri, 20 Sep 2024 19:04:10 +0100 Subject: [PATCH] refactor: re-order PRAGMA statements (#5140) The page_size will soon be made configurable with #5135, making this re-ordering necessary. When opening SQLite connection, there are specific pragmas set with commonPragmas. In particular, PRAGMA journal_mode creates journal file and locks the page_size; as of this commit, this sets the page size to the default value of 4096. Coincidentally, the hardcoded page_size was also 4096, so no issue was noticed. --- src/xrpld/core/DatabaseCon.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/xrpld/core/DatabaseCon.h b/src/xrpld/core/DatabaseCon.h index 219693b11ef..f656d83f9e1 100644 --- a/src/xrpld/core/DatabaseCon.h +++ b/src/xrpld/core/DatabaseCon.h @@ -206,6 +206,12 @@ class DatabaseCon { open(*session_, "sqlite", pPath.string()); + for (auto const& p : pragma) + { + soci::statement st = session_->prepare << p; + st.execute(true); + } + if (commonPragma) { for (auto const& p : *commonPragma) @@ -214,11 +220,7 @@ class DatabaseCon st.execute(true); } } - for (auto const& p : pragma) - { - soci::statement st = session_->prepare << p; - st.execute(true); - } + for (auto const& sql : initSQL) { soci::statement st = session_->prepare << sql;