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.
This commit is contained in:
Timothy Flynn 2022-12-03 07:07:42 -05:00 committed by Andreas Kling
parent aec75d749a
commit f9d23e1d2f
Notes: sideshowbarker 2024-07-17 07:11:12 +09:00
10 changed files with 57 additions and 117 deletions

View file

@ -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)