|
@@ -295,7 +295,15 @@ private:
|
|
// Expressions
|
|
// Expressions
|
|
//==================================================================================================
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
+struct ExecutionContext {
|
|
|
|
+ NonnullRefPtr<Database> database;
|
|
|
|
+ RefPtr<SQLResult> result { nullptr };
|
|
|
|
+ Tuple current_row {};
|
|
|
|
+};
|
|
|
|
+
|
|
class Expression : public ASTNode {
|
|
class Expression : public ASTNode {
|
|
|
|
+public:
|
|
|
|
+ virtual Value evaluate(ExecutionContext&) const;
|
|
};
|
|
};
|
|
|
|
|
|
class ErrorExpression final : public Expression {
|
|
class ErrorExpression final : public Expression {
|
|
@@ -309,6 +317,7 @@ public:
|
|
}
|
|
}
|
|
|
|
|
|
double value() const { return m_value; }
|
|
double value() const { return m_value; }
|
|
|
|
+ virtual Value evaluate(ExecutionContext&) const override;
|
|
|
|
|
|
private:
|
|
private:
|
|
double m_value;
|
|
double m_value;
|
|
@@ -322,6 +331,7 @@ public:
|
|
}
|
|
}
|
|
|
|
|
|
const String& value() const { return m_value; }
|
|
const String& value() const { return m_value; }
|
|
|
|
+ virtual Value evaluate(ExecutionContext&) const override;
|
|
|
|
|
|
private:
|
|
private:
|
|
String m_value;
|
|
String m_value;
|
|
@@ -341,11 +351,14 @@ private:
|
|
};
|
|
};
|
|
|
|
|
|
class NullLiteral : public Expression {
|
|
class NullLiteral : public Expression {
|
|
|
|
+public:
|
|
|
|
+ virtual Value evaluate(ExecutionContext&) const override;
|
|
};
|
|
};
|
|
|
|
|
|
class NestedExpression : public Expression {
|
|
class NestedExpression : public Expression {
|
|
public:
|
|
public:
|
|
const NonnullRefPtr<Expression>& expression() const { return m_expression; }
|
|
const NonnullRefPtr<Expression>& expression() const { return m_expression; }
|
|
|
|
+ virtual Value evaluate(ExecutionContext&) const override;
|
|
|
|
|
|
protected:
|
|
protected:
|
|
explicit NestedExpression(NonnullRefPtr<Expression> expression)
|
|
explicit NestedExpression(NonnullRefPtr<Expression> expression)
|
|
@@ -439,6 +452,7 @@ public:
|
|
}
|
|
}
|
|
|
|
|
|
UnaryOperator type() const { return m_type; }
|
|
UnaryOperator type() const { return m_type; }
|
|
|
|
+ virtual Value evaluate(ExecutionContext&) const override;
|
|
|
|
|
|
private:
|
|
private:
|
|
UnaryOperator m_type;
|
|
UnaryOperator m_type;
|
|
@@ -488,6 +502,7 @@ public:
|
|
}
|
|
}
|
|
|
|
|
|
const NonnullRefPtrVector<Expression>& expressions() const { return m_expressions; }
|
|
const NonnullRefPtrVector<Expression>& expressions() const { return m_expressions; }
|
|
|
|
+ virtual Value evaluate(ExecutionContext&) const override;
|
|
|
|
|
|
private:
|
|
private:
|
|
NonnullRefPtrVector<Expression> m_expressions;
|
|
NonnullRefPtrVector<Expression> m_expressions;
|
|
@@ -667,7 +682,7 @@ private:
|
|
|
|
|
|
class Statement : public ASTNode {
|
|
class Statement : public ASTNode {
|
|
public:
|
|
public:
|
|
- virtual RefPtr<SQLResult> execute(NonnullRefPtr<Database>) const { return nullptr; }
|
|
|
|
|
|
+ virtual RefPtr<SQLResult> execute(ExecutionContext&) const { return nullptr; }
|
|
};
|
|
};
|
|
|
|
|
|
class ErrorStatement final : public Statement {
|
|
class ErrorStatement final : public Statement {
|
|
@@ -684,7 +699,7 @@ public:
|
|
const String& schema_name() const { return m_schema_name; }
|
|
const String& schema_name() const { return m_schema_name; }
|
|
bool is_error_if_schema_exists() const { return m_is_error_if_schema_exists; }
|
|
bool is_error_if_schema_exists() const { return m_is_error_if_schema_exists; }
|
|
|
|
|
|
- RefPtr<SQLResult> execute(NonnullRefPtr<Database>) const override;
|
|
|
|
|
|
+ RefPtr<SQLResult> execute(ExecutionContext&) const override;
|
|
|
|
|
|
private:
|
|
private:
|
|
String m_schema_name;
|
|
String m_schema_name;
|
|
@@ -723,7 +738,7 @@ public:
|
|
bool is_temporary() const { return m_is_temporary; }
|
|
bool is_temporary() const { return m_is_temporary; }
|
|
bool is_error_if_table_exists() const { return m_is_error_if_table_exists; }
|
|
bool is_error_if_table_exists() const { return m_is_error_if_table_exists; }
|
|
|
|
|
|
- RefPtr<SQLResult> execute(NonnullRefPtr<Database>) const override;
|
|
|
|
|
|
+ RefPtr<SQLResult> execute(ExecutionContext&) const override;
|
|
|
|
|
|
private:
|
|
private:
|
|
String m_schema_name;
|
|
String m_schema_name;
|
|
@@ -886,6 +901,8 @@ public:
|
|
bool has_selection() const { return !m_select_statement.is_null(); }
|
|
bool has_selection() const { return !m_select_statement.is_null(); }
|
|
const RefPtr<Select>& select_statement() const { return m_select_statement; }
|
|
const RefPtr<Select>& select_statement() const { return m_select_statement; }
|
|
|
|
|
|
|
|
+ RefPtr<SQLResult> execute(ExecutionContext&) const;
|
|
|
|
+
|
|
private:
|
|
private:
|
|
RefPtr<CommonTableExpressionList> m_common_table_expression_list;
|
|
RefPtr<CommonTableExpressionList> m_common_table_expression_list;
|
|
ConflictResolution m_conflict_resolution;
|
|
ConflictResolution m_conflict_resolution;
|
|
@@ -977,6 +994,7 @@ public:
|
|
const RefPtr<GroupByClause>& group_by_clause() const { return m_group_by_clause; }
|
|
const RefPtr<GroupByClause>& group_by_clause() const { return m_group_by_clause; }
|
|
const NonnullRefPtrVector<OrderingTerm>& ordering_term_list() const { return m_ordering_term_list; }
|
|
const NonnullRefPtrVector<OrderingTerm>& ordering_term_list() const { return m_ordering_term_list; }
|
|
const RefPtr<LimitClause>& limit_clause() const { return m_limit_clause; }
|
|
const RefPtr<LimitClause>& limit_clause() const { return m_limit_clause; }
|
|
|
|
+ RefPtr<SQLResult> execute(ExecutionContext&) const override;
|
|
|
|
|
|
private:
|
|
private:
|
|
RefPtr<CommonTableExpressionList> m_common_table_expression_list;
|
|
RefPtr<CommonTableExpressionList> m_common_table_expression_list;
|