Serenity Operating System
at master 25 lines 634 B view raw
1/* 2 * Copyright (c) 2021, Jan de Visser <jan@de-visser.net> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <LibSQL/AST/AST.h> 8#include <LibSQL/Database.h> 9#include <LibSQL/Meta.h> 10 11namespace SQL::AST { 12 13ResultOr<ResultSet> CreateSchema::execute(ExecutionContext& context) const 14{ 15 auto schema_def = SchemaDef::construct(m_schema_name); 16 17 if (auto result = context.database->add_schema(*schema_def); result.is_error()) { 18 if (result.error().error() != SQLErrorCode::SchemaExists || m_is_error_if_schema_exists) 19 return result.release_error(); 20 } 21 22 return ResultSet { SQLCommand::Create }; 23} 24 25}