Commit 915b67f4 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

sqlite: Connection: Invert checks to fail early

Otherwise we end up deadlocking while acquiring the context. Might as
well fail harder & sooner

(cherry picked from commit f4a842c8)
Signed-off-by: 's avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent 629ded1e
...@@ -140,11 +140,11 @@ void Connection::setPragma( Connection::Handle conn, const std::string& pragmaNa ...@@ -140,11 +140,11 @@ void Connection::setPragma( Connection::Handle conn, const std::string& pragmaNa
void Connection::setForeignKeyEnabled( bool value ) void Connection::setForeignKeyEnabled( bool value )
{ {
// Ensure no transaction will be started during the pragma change
auto ctx = acquireWriteContext();
// Changing this pragma during a transaction is a no-op (silently ignored by // Changing this pragma during a transaction is a no-op (silently ignored by
// sqlite), so ensure we're doing something usefull here: // sqlite), so ensure we're doing something usefull here:
assert( sqlite::Transaction::transactionInProgress() == false ); assert( sqlite::Transaction::transactionInProgress() == false );
// Ensure no transaction will be started during the pragma change
auto ctx = acquireWriteContext();
setPragma( handle(), "foreign_keys", value ? "1" : "0" ); setPragma( handle(), "foreign_keys", value ? "1" : "0" );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment