Commit 2a6924a1 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

SqliteConnection: Avoid getConn calling itself recursively

parent 4bf9ddaf
......@@ -50,10 +50,14 @@ SqliteConnection::Handle SqliteConnection::getConn()
LOG_WARN( "Failed to enable sqlite busy timeout" );
m_conns.emplace(std::this_thread::get_id(), ConnPtr( dbConnection, &sqlite3_close ) );
lock.unlock();
if ( sqlite::Tools::executeRequestLocked( this, "PRAGMA foreign_keys = ON" ) == false )
throw std::runtime_error( "Failed to enable foreign keys" );
if ( sqlite::Tools::executeRequestLocked( this, "PRAGMA recursive_triggers = ON" ) == false )
throw std::runtime_error( "Failed to enable recursive triggers" );
sqlite::Statement s( dbConnection, "PRAGMA foreign_keys = ON" );
s.execute();
while ( s.row() != nullptr )
;
s = sqlite::Statement( dbConnection, "PRAGMA recursive_triggers = ON" );
s.execute();
while ( s.row() != nullptr )
;
return dbConnection;
}
return it->second.get();
......
......@@ -283,9 +283,6 @@ class Tools
std::chrono::duration_cast<std::chrono::microseconds>( duration ).count(), "µs" );
return true;
}
// Let SqliteConnection access executeRequestLocked
friend SqliteConnection;
};
}
......
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