Sqlite: Add busy handler

A busy handler is much more flexible than a timeout. In most cases we can
remove the busy exception handling code.

Change-Id: I59666ccfbd380a341412e3d25e6716b07097bf3c
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2021-03-16 11:48:12 +01:00
parent a6cfbf82ac
commit baab71c073
4 changed files with 48 additions and 25 deletions

View File

@@ -55,13 +55,13 @@ public:
using MutexType = std::mutex;
using ReadStatement = Sqlite::ReadStatement;
using WriteStatement = Sqlite::WriteStatement;
using BusyHandler = DatabaseBackend::BusyHandler;
Database();
Database(Utils::PathString &&databaseFilePath, JournalMode journalMode = JournalMode::Wal);
Database(Utils::PathString &&databaseFilePath,
JournalMode journalMode);
Database(Utils::PathString &&databaseFilePath,
std::chrono::milliseconds busyTimeout = 1000ms,
JournalMode journalMode=JournalMode::Wal);
std::chrono::milliseconds busyTimeout,
JournalMode journalMode = JournalMode::Wal);
~Database();
Database(const Database &) = delete;
@@ -132,6 +132,11 @@ public:
void setAttachedTables(const Utils::SmallStringVector &tables) override;
void applyAndUpdateSessions() override;
void setBusyHandler(BusyHandler busyHandler)
{
m_databaseBackend.setBusyHandler(std::move(busyHandler));
}
SessionChangeSets changeSets() const;
private: