1#include "duckdb/planner/expression/bound_parameter_expression.hpp"
2#include "duckdb/common/types/hash.hpp"
3
4using namespace duckdb;
5using namespace std;
6
7BoundParameterExpression::BoundParameterExpression(idx_t parameter_nr)
8 : Expression(ExpressionType::VALUE_PARAMETER, ExpressionClass::BOUND_PARAMETER, TypeId::INVALID),
9 sql_type(SQLType(SQLTypeId::UNKNOWN)), parameter_nr(parameter_nr), value(nullptr) {
10}
11
12bool BoundParameterExpression::IsScalar() const {
13 return true;
14}
15bool BoundParameterExpression::HasParameter() const {
16 return true;
17}
18bool BoundParameterExpression::IsFoldable() const {
19 return false;
20}
21
22string BoundParameterExpression::ToString() const {
23 return to_string(parameter_nr);
24}
25
26bool BoundParameterExpression::Equals(const BaseExpression *other_) const {
27 if (!BaseExpression::Equals(other_)) {
28 return false;
29 }
30 auto other = (BoundParameterExpression *)other_;
31 return parameter_nr == other->parameter_nr;
32}
33
34hash_t BoundParameterExpression::Hash() const {
35 hash_t result = Expression::Hash();
36 result = CombineHash(duckdb::Hash(parameter_nr), result);
37 result = CombineHash(duckdb::Hash((int)sql_type.id), result);
38 return result;
39}
40
41unique_ptr<Expression> BoundParameterExpression::Copy() {
42 auto result = make_unique<BoundParameterExpression>(parameter_nr);
43 result->sql_type = sql_type;
44 result->value = value;
45 result->return_type = return_type;
46 return move(result);
47}
48