1#include "duckdb/parser/statement/set_statement.hpp"
2#include "duckdb/planner/binder.hpp"
3#include "duckdb/planner/operator/logical_set.hpp"
4#include "duckdb/planner/operator/logical_reset.hpp"
5#include <algorithm>
6
7namespace duckdb {
8
9BoundStatement Binder::Bind(SetVariableStatement &stmt) {
10 BoundStatement result;
11 result.types = {LogicalType::BOOLEAN};
12 result.names = {"Success"};
13
14 result.plan = make_uniq<LogicalSet>(args&: stmt.name, args&: stmt.value, args&: stmt.scope);
15 properties.return_type = StatementReturnType::NOTHING;
16 return result;
17}
18
19BoundStatement Binder::Bind(ResetVariableStatement &stmt) {
20 BoundStatement result;
21 result.types = {LogicalType::BOOLEAN};
22 result.names = {"Success"};
23
24 result.plan = make_uniq<LogicalReset>(args&: stmt.name, args&: stmt.scope);
25 properties.return_type = StatementReturnType::NOTHING;
26 return result;
27}
28
29BoundStatement Binder::Bind(SetStatement &stmt) {
30 switch (stmt.set_type) {
31 case SetType::SET: {
32 auto &set_stmt = stmt.Cast<SetVariableStatement>();
33 return Bind(stmt&: set_stmt);
34 }
35 case SetType::RESET: {
36 auto &set_stmt = stmt.Cast<ResetVariableStatement>();
37 return Bind(stmt&: set_stmt);
38 }
39 default:
40 throw NotImplementedException("Type not implemented for SetType");
41 }
42}
43
44} // namespace duckdb
45