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

@@ -61,7 +61,7 @@ Database::Database()
}
Database::Database(Utils::PathString &&databaseFilePath, JournalMode journalMode)
: Database(std::move(databaseFilePath), 1000ms, journalMode)
: Database{std::move(databaseFilePath), 0ms, journalMode}
{}
Database::Database(Utils::PathString &&databaseFilePath,
@@ -89,7 +89,10 @@ void Database::open()
{
m_databaseBackend.open(m_databaseFilePath, m_openMode);
m_databaseBackend.setJournalMode(m_journalMode);
m_databaseBackend.setBusyTimeout(m_busyTimeout);
if (m_busyTimeout > 0ms)
m_databaseBackend.setBusyTimeout(m_busyTimeout);
else
m_databaseBackend.registerBusyHandler();
registerTransactionStatements();
initializeTables();
m_isOpen = true;