/Users/deen/code/yugabyte-db/src/yb/yql/cql/ql/ptree/pt_truncate.h
Line | Count | Source (jump to first uncovered line) |
1 | | //-------------------------------------------------------------------------------------------------- |
2 | | // Copyright (c) YugaByte, Inc. |
3 | | // |
4 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
5 | | // in compliance with the License. You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
10 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
11 | | // or implied. See the License for the specific language governing permissions and limitations |
12 | | // under the License. |
13 | | // |
14 | | // |
15 | | // Tree node definitions for TRUNCATE statement. |
16 | | //-------------------------------------------------------------------------------------------------- |
17 | | |
18 | | #ifndef YB_YQL_CQL_QL_PTREE_PT_TRUNCATE_H_ |
19 | | #define YB_YQL_CQL_QL_PTREE_PT_TRUNCATE_H_ |
20 | | |
21 | | #include "yb/yql/cql/ql/ptree/list_node.h" |
22 | | #include "yb/yql/cql/ql/ptree/tree_node.h" |
23 | | #include "yb/yql/cql/ql/ptree/pt_type.h" |
24 | | #include "yb/yql/cql/ql/ptree/pt_name.h" |
25 | | #include "yb/yql/cql/ql/ptree/pt_option.h" |
26 | | |
27 | | namespace yb { |
28 | | namespace ql { |
29 | | |
30 | | //-------------------------------------------------------------------------------------------------- |
31 | | // TRUNCATE statement. |
32 | | |
33 | | class PTTruncateStmt : public TreeNode { |
34 | | public: |
35 | | //------------------------------------------------------------------------------------------------ |
36 | | // Public types. |
37 | | typedef MCSharedPtr<PTTruncateStmt> SharedPtr; |
38 | | typedef MCSharedPtr<const PTTruncateStmt> SharedPtrConst; |
39 | | |
40 | | //------------------------------------------------------------------------------------------------ |
41 | | // Constructor and destructor. |
42 | | PTTruncateStmt(MemoryContext *memctx, |
43 | | YBLocationPtr loc, |
44 | | PTQualifiedNameListNode::SharedPtr names); |
45 | | virtual ~PTTruncateStmt(); |
46 | | |
47 | | // Node type. |
48 | 20.8k | virtual TreeNodeOpcode opcode() const override { |
49 | 20.8k | return TreeNodeOpcode::kPTTruncateStmt; |
50 | 20.8k | } |
51 | | |
52 | | // Support for shared_ptr. |
53 | | template<typename... TypeArgs> |
54 | 3.04k | inline static PTTruncateStmt::SharedPtr MakeShared(MemoryContext *memctx, TypeArgs&&... args) { |
55 | 3.04k | return MCMakeShared<PTTruncateStmt>(memctx, std::forward<TypeArgs>(args)...); |
56 | 3.04k | } |
57 | | |
58 | | // Node semantics analysis. |
59 | | virtual CHECKED_STATUS Analyze(SemContext *sem_context) override; |
60 | | void PrintSemanticAnalysisResult(SemContext *sem_context); |
61 | | |
62 | | // Name of the table being truncated. |
63 | 6.09k | const PTQualifiedName::SharedPtr name() const { |
64 | 6.09k | return names_->element(0); |
65 | 6.09k | } |
66 | | |
67 | | // Id of the table being truncated. |
68 | | const std::string& table_id() const; |
69 | | |
70 | 8.89k | client::YBTableName yb_table_name() const { |
71 | 8.89k | return names_->element(0)->ToTableName(); |
72 | 8.89k | } |
73 | | |
74 | 0 | const std::shared_ptr<client::YBTable>& table() const { |
75 | 0 | return table_; |
76 | 0 | } |
77 | | |
78 | | private: |
79 | | PTQualifiedNameListNode::SharedPtr names_; |
80 | | |
81 | | // The semantic analyzer will decorate the following information. |
82 | | std::shared_ptr<client::YBTable> table_; |
83 | | }; |
84 | | |
85 | | } // namespace ql |
86 | | } // namespace yb |
87 | | |
88 | | #endif // YB_YQL_CQL_QL_PTREE_PT_TRUNCATE_H_ |