1#include "duckdb/parser/expression/parameter_expression.hpp"
2
3#include "duckdb/common/exception.hpp"
4#include "duckdb/common/serializer.hpp"
5#include "duckdb/common/types/hash.hpp"
6
7using namespace duckdb;
8using namespace std;
9
10ParameterExpression::ParameterExpression()
11 : ParsedExpression(ExpressionType::VALUE_PARAMETER, ExpressionClass::PARAMETER), parameter_nr(0) {
12}
13
14string ParameterExpression::ToString() const {
15 return "$" + std::to_string(parameter_nr);
16}
17
18unique_ptr<ParsedExpression> ParameterExpression::Copy() const {
19 auto copy = make_unique<ParameterExpression>();
20 copy->CopyProperties(*this);
21 return move(copy);
22}
23
24hash_t ParameterExpression::Hash() const {
25 hash_t result = ParsedExpression::Hash();
26 return CombineHash(duckdb::Hash(parameter_nr), result);
27}
28
29void ParameterExpression::Serialize(Serializer &serializer) {
30 ParsedExpression::Serialize(serializer);
31 serializer.Write<idx_t>(parameter_nr);
32}
33
34unique_ptr<ParsedExpression> ParameterExpression::Deserialize(ExpressionType type, Deserializer &source) {
35 auto expression = make_unique<ParameterExpression>();
36 expression->parameter_nr = source.Read<idx_t>();
37 return move(expression);
38}
39