/* * Copyright (c) 2021, Jan de Visser * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include namespace SQLServer { class SQLStatement final : public Core::Object { C_OBJECT_ABSTRACT(SQLStatement) public: static SQL::ResultOr> create(DatabaseConnection&, StringView sql); ~SQLStatement() override = default; static RefPtr statement_for(u64 statement_id); u64 statement_id() const { return m_statement_id; } DatabaseConnection* connection() { return dynamic_cast(parent()); } Optional execute(Vector placeholder_values); private: SQLStatement(DatabaseConnection&, NonnullRefPtr statement); bool should_send_result_rows() const; void next(u64 execution_id); void report_error(SQL::Result, u64 execution_id); u64 m_statement_id { 0 }; size_t m_index { 0 }; HashTable m_ongoing_executions; u64 m_next_execution_id { 0 }; NonnullRefPtr m_statement; Optional m_result {}; }; }