Minor db cleanup

This commit is contained in:
emeric
2024-05-08 16:37:43 +02:00
parent c6104c06ea
commit 06b071553c
5 changed files with 14 additions and 27 deletions
+3 -13
View File
@@ -50,12 +50,6 @@ namespace lms::db
prepare();
}
~Connection() override
{
// make use of per-connection usage stats to optimize
optimize();
}
private:
Connection& operator=(const Connection&) = delete;
@@ -72,13 +66,6 @@ namespace lms::db
LMS_LOG(DB, DEBUG, "Setting per-connection settings done!");
}
void optimize()
{
LMS_LOG(DB, DEBUG, "connection close: Running pragma optimize...");
executeSql("PRAGMA optimize");
LMS_LOG(DB, DEBUG, "connection close: pragma optimize complete");
}
std::filesystem::path _dbPath;
};
}
@@ -119,6 +106,9 @@ namespace lms::db
}
}
// For now, multiple databases are not handled
assert(&tlsSession->getDb() == this);
return *tlsSession;
}
+1 -2
View File
@@ -73,13 +73,12 @@ namespace lms::db::Migration
{
_db.executeSql("PRAGMA foreign_keys=ON");
}
private:
ScopedNoForeignKeys(const ScopedNoForeignKeys&) = delete;
ScopedNoForeignKeys(ScopedNoForeignKeys&&) = delete;
ScopedNoForeignKeys& operator=(const ScopedNoForeignKeys&) = delete;
ScopedNoForeignKeys& operator=(ScopedNoForeignKeys&&) = delete;
private:
Db& _db;
};
-2
View File
@@ -19,8 +19,6 @@
#include "database/Session.hpp"
#include <cassert>
#include "core/Exception.hpp"
#include "core/ILogger.hpp"
#include "core/ITraceLogger.hpp"
+10 -8
View File
@@ -91,10 +91,18 @@ namespace lms::db::tests
EXPECT_EQ(User::getCount(session), 0);
}
TEST_F(DatabaseFixture, vacuum)
{
session.vacuum();
}
TEST_F(DatabaseFixture, analyze)
{
session.fullAnalyze();
}
TEST_F(DatabaseFixture, Common_subRangeEmpty)
{
using namespace db;
RangeResults<int> results;
results.range = Range{ 0, 0 };
results.results = {};
@@ -115,8 +123,6 @@ namespace lms::db::tests
TEST_F(DatabaseFixture, Common_subRangeForeach)
{
using namespace db;
struct TestCase
{
Range range;
@@ -153,8 +159,6 @@ namespace lms::db::tests
TEST_F(DatabaseFixture, Common_IdType)
{
using namespace db;
{
const IdType id{};
EXPECT_FALSE(id.isValid());
@@ -182,8 +186,6 @@ namespace lms::db::tests
TEST_F(DatabaseFixture, Common_subRange)
{
using namespace db;
RangeResults<int> results;
results.range = Range{ 0, 2 };
results.results = { 5, 6 };
-2
View File
@@ -27,8 +27,6 @@ namespace lms::db::tests
{
void executeStatements(db::Session& session, std::string_view statements)
{
auto transaction{ session.createWriteTransaction() };
for (std::string_view statement : core::stringUtils::splitString(statements, ';'))
{
statement = core::stringUtils::stringTrim(statement, " \t\r\n");