mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 11:37:16 +02:00
LibSQL: Invent statement execution machinery and CREATE SCHEMA statement
This patch introduces the ability execute parsed SQL statements. The abstract AST Statement node now has a virtual 'execute' method. This method takes a Database object as parameter and returns a SQLResult object. Also introduced here is the CREATE SCHEMA statement. Tables live in a schema, and if no schema is present in a table reference the 'default' schema is implied. This schema is created if it doesn't yet exist when a Database object is created. Finally, as a proof of concept, the CREATE SCHEMA and CREATE TABLE statements received an 'execute' implementation. The CREATE TABLE method is not able to create tables created from SQL queries yet.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
30691549fd
commit
1037d6b0eb
Notes:
sideshowbarker
2024-07-18 10:04:39 +09:00
Author: https://github.com/JanDeVisser Commit: https://github.com/SerenityOS/serenity/commit/1037d6b0eb4 Pull-request: https://github.com/SerenityOS/serenity/pull/8306 Reviewed-by: https://github.com/MaxWipfli Reviewed-by: https://github.com/alimpfard ✅ Reviewed-by: https://github.com/trflynn89 ✅
@@ -666,11 +666,31 @@ private:
|
||||
//==================================================================================================
|
||||
|
||||
class Statement : public ASTNode {
|
||||
public:
|
||||
virtual RefPtr<SQLResult> execute(NonnullRefPtr<Database>) const { return nullptr; }
|
||||
};
|
||||
|
||||
class ErrorStatement final : public Statement {
|
||||
};
|
||||
|
||||
class CreateSchema : public Statement {
|
||||
public:
|
||||
CreateSchema(String schema_name, bool is_error_if_schema_exists)
|
||||
: m_schema_name(move(schema_name))
|
||||
, m_is_error_if_schema_exists(is_error_if_schema_exists)
|
||||
{
|
||||
}
|
||||
|
||||
const String& schema_name() const { return m_schema_name; }
|
||||
bool is_error_if_schema_exists() const { return m_is_error_if_schema_exists; }
|
||||
|
||||
RefPtr<SQLResult> execute(NonnullRefPtr<Database>) const override;
|
||||
|
||||
private:
|
||||
String m_schema_name;
|
||||
bool m_is_error_if_schema_exists;
|
||||
};
|
||||
|
||||
class CreateTable : public Statement {
|
||||
public:
|
||||
CreateTable(String schema_name, String table_name, RefPtr<Select> select_statement, bool is_temporary, bool is_error_if_table_exists)
|
||||
@@ -703,6 +723,8 @@ public:
|
||||
bool is_temporary() const { return m_is_temporary; }
|
||||
bool is_error_if_table_exists() const { return m_is_error_if_table_exists; }
|
||||
|
||||
RefPtr<SQLResult> execute(NonnullRefPtr<Database>) const override;
|
||||
|
||||
private:
|
||||
String m_schema_name;
|
||||
String m_table_name;
|
||||
|
||||
Reference in New Issue
Block a user