summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSQL
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/Libraries/LibSQL
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/Libraries/LibSQL')
-rw-r--r--Userland/Libraries/LibSQL/SQLClient.cpp20
-rw-r--r--Userland/Libraries/LibSQL/SQLClient.h6
2 files changed, 0 insertions, 26 deletions
diff --git a/Userland/Libraries/LibSQL/SQLClient.cpp b/Userland/Libraries/LibSQL/SQLClient.cpp
index 3b1bd35f44..4a5a2693ec 100644
--- a/Userland/Libraries/LibSQL/SQLClient.cpp
+++ b/Userland/Libraries/LibSQL/SQLClient.cpp
@@ -9,26 +9,6 @@
namespace SQL {
-void SQLClient::connected(u64 connection_id, DeprecatedString const& connected_to_database)
-{
- if (on_connected)
- on_connected(connection_id, connected_to_database);
-}
-
-void SQLClient::disconnected(u64 connection_id)
-{
- if (on_disconnected)
- on_disconnected(connection_id);
-}
-
-void SQLClient::connection_error(u64 connection_id, SQLErrorCode const& code, DeprecatedString const& message)
-{
- if (on_connection_error)
- on_connection_error(connection_id, code, message);
- else
- warnln("Connection error for connection_id {}: {} ({})", connection_id, message, to_underlying(code));
-}
-
void SQLClient::execution_error(u64 statement_id, u64 execution_id, SQLErrorCode const& code, DeprecatedString const& message)
{
if (on_execution_error)
diff --git a/Userland/Libraries/LibSQL/SQLClient.h b/Userland/Libraries/LibSQL/SQLClient.h
index 52ecb33375..ae45d852de 100644
--- a/Userland/Libraries/LibSQL/SQLClient.h
+++ b/Userland/Libraries/LibSQL/SQLClient.h
@@ -20,9 +20,6 @@ class SQLClient
IPC_CLIENT_CONNECTION(SQLClient, "/tmp/session/%sid/portal/sql"sv)
virtual ~SQLClient() = default;
- Function<void(u64, DeprecatedString const&)> on_connected;
- Function<void(u64)> on_disconnected;
- Function<void(u64, SQLErrorCode, DeprecatedString const&)> on_connection_error;
Function<void(u64, u64, SQLErrorCode, DeprecatedString const&)> on_execution_error;
Function<void(u64, u64, bool, size_t, size_t, size_t)> on_execution_success;
Function<void(u64, u64, Vector<DeprecatedString> const&)> on_next_result;
@@ -34,13 +31,10 @@ private:
{
}
- virtual void connected(u64 connection_id, DeprecatedString const& connected_to_database) override;
- virtual void connection_error(u64 connection_id, SQLErrorCode const& code, DeprecatedString const& message) override;
virtual void execution_success(u64 statement_id, u64 execution_id, bool has_results, size_t created, size_t updated, size_t deleted) override;
virtual void next_result(u64 statement_id, u64 execution_id, Vector<DeprecatedString> const&) override;
virtual void results_exhausted(u64 statement_id, u64 execution_id, size_t total_rows) override;
virtual void execution_error(u64 statement_id, u64 execution_id, SQLErrorCode const& code, DeprecatedString const& message) override;
- virtual void disconnected(u64 connection_id) override;
};
}