mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00:00
SQLServer: Parse SQL a single time to actually "prepare" the statement
One of the benefits of prepared statements is that the SQL string is parsed just once and re-used. This updates SQLStatement to do just that and store the parsed result.
This commit is contained in:
parent
83bb25611e
commit
b13527b8b2
5 changed files with 40 additions and 39 deletions
|
@ -18,28 +18,27 @@
|
|||
namespace SQLServer {
|
||||
|
||||
class SQLStatement final : public Core::Object {
|
||||
C_OBJECT(SQLStatement)
|
||||
C_OBJECT_ABSTRACT(SQLStatement)
|
||||
|
||||
public:
|
||||
static SQL::ResultOr<NonnullRefPtr<SQLStatement>> create(DatabaseConnection&, StringView sql);
|
||||
~SQLStatement() override = default;
|
||||
|
||||
static RefPtr<SQLStatement> statement_for(int statement_id);
|
||||
int statement_id() const { return m_statement_id; }
|
||||
DeprecatedString const& sql() const { return m_sql; }
|
||||
DatabaseConnection* connection() { return dynamic_cast<DatabaseConnection*>(parent()); }
|
||||
void execute();
|
||||
|
||||
private:
|
||||
SQLStatement(DatabaseConnection&, DeprecatedString sql);
|
||||
SQL::ResultOr<void> parse();
|
||||
SQLStatement(DatabaseConnection&, NonnullRefPtr<SQL::AST::Statement> statement);
|
||||
|
||||
bool should_send_result_rows() const;
|
||||
void next();
|
||||
void report_error(SQL::Result);
|
||||
|
||||
int m_statement_id;
|
||||
DeprecatedString m_sql;
|
||||
size_t m_index { 0 };
|
||||
RefPtr<SQL::AST::Statement> m_statement { nullptr };
|
||||
NonnullRefPtr<SQL::AST::Statement> m_statement;
|
||||
Optional<SQL::ResultSet> m_result {};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue