/Users/deen/code/yugabyte-db/src/yb/yql/cql/ql/ptree/pt_alter_keyspace.cc
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 | | // Treenode definitions for ALTER KEYSPACE statements. |
16 | | //-------------------------------------------------------------------------------------------------- |
17 | | |
18 | | #include "yb/yql/cql/ql/ptree/pt_alter_keyspace.h" |
19 | | |
20 | | #include "yb/common/redis_constants_common.h" |
21 | | |
22 | | #include "yb/yql/cql/ql/ptree/sem_context.h" |
23 | | #include "yb/yql/cql/ql/ptree/yb_location.h" |
24 | | |
25 | | DECLARE_bool(use_cassandra_authentication); |
26 | | |
27 | | namespace yb { |
28 | | namespace ql { |
29 | | |
30 | | //-------------------------------------------------------------------------------------------------- |
31 | | |
32 | | PTAlterKeyspace::PTAlterKeyspace(MemoryContext *memctx, |
33 | | YBLocation::SharedPtr loc, |
34 | | const MCSharedPtr<MCString>& name, |
35 | | const PTKeyspacePropertyListNode::SharedPtr& keyspace_properties) |
36 | | : TreeNode(memctx, loc), |
37 | | name_(name), |
38 | 44 | keyspace_properties_(keyspace_properties) { |
39 | 44 | } |
40 | | |
41 | 44 | PTAlterKeyspace::~PTAlterKeyspace() { |
42 | 44 | } |
43 | | |
44 | 44 | CHECKED_STATUS PTAlterKeyspace::Analyze(SemContext *sem_context) { |
45 | 44 | if (*name_ == common::kRedisKeyspaceName) { |
46 | 0 | return sem_context->Error(loc(), |
47 | 0 | strings::Substitute("$0 is a reserved keyspace name", |
48 | 0 | common::kRedisKeyspaceName).c_str(), |
49 | 0 | ErrorCode::INVALID_ARGUMENTS); |
50 | 0 | } |
51 | | |
52 | | // Check permissions. |
53 | 44 | if (FLAGS_use_cassandra_authentication) { |
54 | 44 | RETURN_NOT_OK(sem_context->CheckHasKeyspacePermission(loc(), |
55 | 44 | PermissionType::ALTER_PERMISSION, name())); |
56 | 44 | } |
57 | | |
58 | 43 | if (keyspace_properties_ != nullptr) { |
59 | | // Process keyspace properties. |
60 | 41 | RETURN_NOT_OK(keyspace_properties_->Analyze(sem_context)); |
61 | 41 | } |
62 | | |
63 | 21 | if (VLOG_IS_ON(3)) { |
64 | 0 | PrintSemanticAnalysisResult(sem_context); |
65 | 0 | } |
66 | | |
67 | 21 | return Status::OK(); |
68 | 43 | } |
69 | | |
70 | 0 | void PTAlterKeyspace::PrintSemanticAnalysisResult(SemContext *sem_context) { |
71 | 0 | MCString sem_output("\tKeyspace ", sem_context->PTempMem()); |
72 | 0 | sem_output += name(); |
73 | 0 | VLOG(3) << "SEMANTIC ANALYSIS RESULT (" << loc() << "):\n" << sem_output; |
74 | 0 | } |
75 | | |
76 | | } // namespace ql |
77 | | } // namespace yb |