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

LibSQL+SQLServer: Build SQLServer system service

This patch introduces the SQLServer system server. This service is
supposed to be the only process/application talking to database storage.
This makes things like locking and caching more reliable, easier to
implement, and more efficient.

In LibSQL we added a client component that does the ugly IPC nitty-
gritty for you. All that's needed is setting a number of event handler
lambdas and you can connect to databases and execute statements on them.

Applications that wish to use this SQLClient class obviously need to
link LibSQL and LibIPC.
This commit is contained in:
Jan de Visser 2021-06-28 21:15:17 -04:00 committed by Ali Mohammad Pur
parent 1037d6b0eb
commit a034774e3a
19 changed files with 650 additions and 12 deletions

View file

@ -0,0 +1,42 @@
/*
* Copyright (c) 2021, Jan de Visser <jan@de-visser.net>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullRefPtr.h>
#include <AK/String.h>
#include <LibCore/Object.h>
#include <LibSQL/AST/AST.h>
#include <LibSQL/SQLResult.h>
#include <SQLServer/DatabaseConnection.h>
#include <SQLServer/Forward.h>
namespace SQLServer {
class SQLStatement final : public Core::Object {
C_OBJECT(SQLStatement)
~SQLStatement() override = default;
static RefPtr<SQLStatement> statement_for(int statement_id);
int statement_id() const { return m_statement_id; }
String const& sql() const { return m_sql; }
DatabaseConnection* connection() { return dynamic_cast<DatabaseConnection*>(parent()); }
void execute();
private:
SQLStatement(DatabaseConnection&, String sql);
Optional<SQL::SQLError> parse();
void next();
void report_error(SQL::SQLError);
int m_statement_id;
String m_sql;
size_t m_index { 0 };
RefPtr<SQL::AST::Statement> m_statement { nullptr };
RefPtr<SQL::SQLResult> m_result { nullptr };
};
}