summaryrefslogtreecommitdiff
path: root/Userland/Services/SQLServer/SQLStatement.cpp
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-12-03 07:07:42 -0500
committerAndreas Kling <kling@serenityos.org>2022-12-07 13:09:00 +0100
commitf9d23e1d2f7e16300d45c67827256a14eee2aa24 (patch)
treedb714ccbfcdbb2d74858e9509f4758f5d88f69ec /Userland/Services/SQLServer/SQLStatement.cpp
parentaec75d749a09ed2c4974cc26a0c1fa695ac49ed5 (diff)
downloadserenity-f9d23e1d2f7e16300d45c67827256a14eee2aa24.zip
LibSQL+SQLServer+SQLStudio+sql: Propagate connection errors immediately
Currently, when clients connect to SQL server, we inform them of any errors opening the database via an asynchronous IPC. But we already know about these errors before returning from the connect() IPC, so this roundabout propagation is a bit unnecessary. Now if we fail to open the database, we will simply not send back a valid connection ID. Disconnect has a similar story. Rather than disconnecting and invoking an asynchronous IPC to inform the client of the disconnect, make the disconnect() IPC synchronous (because all it does is remove the database from the map of open databases). Further, the only user of this command is the SQL REPL when it wants to connect to a different database, so it makes sense to block it. This did require moving a bit of logic around in the REPL to accommodate this change.
Diffstat (limited to 'Userland/Services/SQLServer/SQLStatement.cpp')
-rw-r--r--Userland/Services/SQLServer/SQLStatement.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/Userland/Services/SQLServer/SQLStatement.cpp b/Userland/Services/SQLServer/SQLStatement.cpp
index cce1528f05..a1049bd835 100644
--- a/Userland/Services/SQLServer/SQLStatement.cpp
+++ b/Userland/Services/SQLServer/SQLStatement.cpp
@@ -74,9 +74,7 @@ Optional<u64> SQLStatement::execute(Vector<SQL::Value> placeholder_values)
m_ongoing_executions.set(execution_id);
deferred_invoke([this, placeholder_values = move(placeholder_values), execution_id] {
- VERIFY(!connection()->database().is_null());
-
- auto execution_result = m_statement->execute(connection()->database().release_nonnull(), placeholder_values);
+ auto execution_result = m_statement->execute(connection()->database(), placeholder_values);
m_ongoing_executions.remove(execution_id);
if (execution_result.is_error()) {