/Users/deen/code/yugabyte-db/src/yb/yql/cql/ql/ptree/pt_create_keyspace.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 CREATE KEYSPACE statement. |
16 | | //-------------------------------------------------------------------------------------------------- |
17 | | |
18 | | #ifndef YB_YQL_CQL_QL_PTREE_PT_CREATE_KEYSPACE_H_ |
19 | | #define YB_YQL_CQL_QL_PTREE_PT_CREATE_KEYSPACE_H_ |
20 | | |
21 | | #include "yb/yql/cql/ql/ptree/tree_node.h" |
22 | | #include "yb/yql/cql/ql/ptree/pt_keyspace_property.h" |
23 | | |
24 | | namespace yb { |
25 | | namespace ql { |
26 | | |
27 | | //-------------------------------------------------------------------------------------------------- |
28 | | // CREATE KEYSPACE statement. |
29 | | |
30 | | class PTCreateKeyspace : public TreeNode { |
31 | | public: |
32 | | //------------------------------------------------------------------------------------------------ |
33 | | // Public types. |
34 | | typedef MCSharedPtr<PTCreateKeyspace> SharedPtr; |
35 | | typedef MCSharedPtr<const PTCreateKeyspace> SharedPtrConst; |
36 | | |
37 | | //------------------------------------------------------------------------------------------------ |
38 | | // Constructor and destructor. |
39 | | PTCreateKeyspace(MemoryContext *memctx, |
40 | | YBLocationPtr loc, |
41 | | const MCSharedPtr<MCString>& name, |
42 | | bool create_if_not_exists, |
43 | | const PTKeyspacePropertyListNode::SharedPtr& keyspace_properties); |
44 | | virtual ~PTCreateKeyspace(); |
45 | | |
46 | | template<typename... TypeArgs> |
47 | 1.76k | inline static PTCreateKeyspace::SharedPtr MakeShared(MemoryContext *memctx, TypeArgs&&... args) { |
48 | 1.76k | return MCMakeShared<PTCreateKeyspace>(memctx, std::forward<TypeArgs>(args)...); |
49 | 1.76k | } |
50 | | |
51 | | // Node type. |
52 | 7.78k | virtual TreeNodeOpcode opcode() const override { |
53 | 7.78k | return TreeNodeOpcode::kPTCreateKeyspace; |
54 | 7.78k | } |
55 | | |
56 | | // Node semantics analysis. |
57 | | virtual CHECKED_STATUS Analyze(SemContext *sem_context) override; |
58 | | void PrintSemanticAnalysisResult(SemContext *sem_context); |
59 | | |
60 | 4 | bool create_if_not_exists() const { |
61 | 4 | return create_if_not_exists_; |
62 | 4 | } |
63 | | |
64 | | // Keyspace name. |
65 | 3.37k | const char* name() const { |
66 | 3.37k | return name_->c_str(); |
67 | 3.37k | } |
68 | | |
69 | 0 | PTKeyspacePropertyListNode::SharedPtr keyspace_properties() const { |
70 | 0 | return keyspace_properties_; |
71 | 0 | } |
72 | | |
73 | | private: |
74 | | MCSharedPtr<MCString> name_; |
75 | | bool create_if_not_exists_; |
76 | | const PTKeyspacePropertyListNode::SharedPtr keyspace_properties_; |
77 | | }; |
78 | | |
79 | | } // namespace ql |
80 | | } // namespace yb |
81 | | |
82 | | #endif // YB_YQL_CQL_QL_PTREE_PT_CREATE_KEYSPACE_H_ |