1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:17:35 +00:00

SQLServer: Re-use already opened SQL::Database objects

Currently, we create a new SQL::Database object for each database we are
requested to open. When multiple clients connect to the same database,
the same underlying database file is opened and cached each time. This
results in updates from one client not being propagated to others.

To prevent this, when a database is requested to be open, check if it is
already open. We can then re-use that SQL::Database object for the new
connection.
This commit is contained in:
Timothy Flynn 2022-12-09 14:52:43 -05:00 committed by Tim Flynn
parent 6b64485b40
commit 12152a4556
2 changed files with 13 additions and 2 deletions

View file

@ -26,6 +26,7 @@ public:
SQL::ConnectionID connection_id() const { return m_connection_id; }
int client_id() const { return m_client_id; }
NonnullRefPtr<SQL::Database> database() { return m_database; }
StringView database_name() const { return m_database_name; }
void disconnect();
SQL::ResultOr<SQL::StatementID> prepare_statement(StringView sql);