1#include "duckdb/parser/query_node/recursive_cte_node.hpp"
2
3using namespace duckdb;
4using namespace std;
5
6bool RecursiveCTENode::Equals(const QueryNode *other_) const {
7 if (!QueryNode::Equals(other_)) {
8 return false;
9 }
10 if (this == other_) {
11 return true;
12 }
13 auto other = (RecursiveCTENode *)other_;
14
15 if (other->union_all != union_all) {
16 return false;
17 }
18 if (!left->Equals(other->left.get())) {
19 return false;
20 }
21 if (!right->Equals(other->right.get())) {
22 return false;
23 }
24 return true;
25}
26
27unique_ptr<QueryNode> RecursiveCTENode::Copy() {
28 auto result = make_unique<RecursiveCTENode>();
29 result->ctename = ctename;
30 result->union_all = union_all;
31 result->left = left->Copy();
32 result->right = right->Copy();
33 this->CopyProperties(*result);
34 return move(result);
35}
36
37void RecursiveCTENode::Serialize(Serializer &serializer) {
38 QueryNode::Serialize(serializer);
39 serializer.WriteString(ctename);
40 serializer.WriteString(union_all ? "T" : "F");
41 left->Serialize(serializer);
42 right->Serialize(serializer);
43}
44
45unique_ptr<QueryNode> RecursiveCTENode::Deserialize(Deserializer &source) {
46 auto result = make_unique<RecursiveCTENode>();
47 result->ctename = source.Read<string>();
48 result->union_all = source.Read<string>() == "T" ? true : false;
49 result->left = QueryNode::Deserialize(source);
50 result->right = QueryNode::Deserialize(source);
51 return move(result);
52}
53