YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/yql/cql/ql/ptree/pt_drop.h
Line
Count
Source
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 DROP statement.
16
//--------------------------------------------------------------------------------------------------
17
18
#ifndef YB_YQL_CQL_QL_PTREE_PT_DROP_H_
19
#define YB_YQL_CQL_QL_PTREE_PT_DROP_H_
20
21
#include "yb/yql/cql/ql/ptree/list_node.h"
22
#include "yb/yql/cql/ql/ptree/pt_name.h"
23
#include "yb/yql/cql/ql/ptree/tree_node.h"
24
25
namespace yb {
26
namespace ql {
27
28
//--------------------------------------------------------------------------------------------------
29
// DROP <OBJECT> statement (<OBJECT> can be TABLE, KEYSPACE, etc.).
30
31
class PTDropStmt : public TreeNode {
32
 public:
33
  //------------------------------------------------------------------------------------------------
34
  // Public types.
35
  typedef MCSharedPtr<PTDropStmt> SharedPtr;
36
  typedef MCSharedPtr<const PTDropStmt> SharedPtrConst;
37
38
  //------------------------------------------------------------------------------------------------
39
  // Constructor and destructor.
40
  PTDropStmt(MemoryContext *memctx,
41
             YBLocationPtr loc,
42
             ObjectType drop_type,
43
             PTQualifiedNameListNode::SharedPtr names,
44
             bool drop_if_exists);
45
  virtual ~PTDropStmt();
46
47
  // Node type.
48
16.4k
  virtual TreeNodeOpcode opcode() const override {
49
16.4k
    return TreeNodeOpcode::kPTDropStmt;
50
16.4k
  }
51
52
  // Support for shared_ptr.
53
  template<typename... TypeArgs>
54
3.55k
  inline static PTDropStmt::SharedPtr MakeShared(MemoryContext *memctx, TypeArgs&&... args) {
55
3.55k
    return MCMakeShared<PTDropStmt>(memctx, std::forward<TypeArgs>(args)...);
56
3.55k
  }
_ZN2yb2ql10PTDropStmt10MakeSharedIJNSt3__110shared_ptrINS0_8LocationEEERNS0_10ObjectTypeERNS4_INS0_12TreeListNodeINS0_15PTQualifiedNameEEEEEbEEENS4_IS1_EEPNS_8internal9ArenaBaseINSF_11ArenaTraitsEEEDpOT_
Line
Count
Source
54
2.81k
  inline static PTDropStmt::SharedPtr MakeShared(MemoryContext *memctx, TypeArgs&&... args) {
55
2.81k
    return MCMakeShared<PTDropStmt>(memctx, std::forward<TypeArgs>(args)...);
56
2.81k
  }
_ZN2yb2ql10PTDropStmt10MakeSharedIJNSt3__110shared_ptrINS0_8LocationEEENS0_10ObjectTypeERNS4_INS0_12TreeListNodeINS0_15PTQualifiedNameEEEEEbEEENS4_IS1_EEPNS_8internal9ArenaBaseINSE_11ArenaTraitsEEEDpOT_
Line
Count
Source
54
737
  inline static PTDropStmt::SharedPtr MakeShared(MemoryContext *memctx, TypeArgs&&... args) {
55
737
    return MCMakeShared<PTDropStmt>(memctx, std::forward<TypeArgs>(args)...);
56
737
  }
57
58
  // Node semantics analysis.
59
  virtual CHECKED_STATUS Analyze(SemContext *sem_context) override;
60
  void PrintSemanticAnalysisResult(SemContext *sem_context);
61
62
11.0k
  ObjectType drop_type() const {
63
11.0k
    return drop_type_;
64
11.0k
  }
65
66
20
  bool drop_if_exists() const {
67
20
    return drop_if_exists_;
68
20
  }
69
70
  // Name of the object being dropped.
71
8.15k
  const PTQualifiedName::SharedPtr name() const {
72
8.15k
    return names_->element(0);
73
8.15k
  }
74
75
3.80k
  client::YBTableName yb_table_name() const {
76
3.80k
    return names_->element(0)->ToTableName();
77
3.80k
  }
78
79
 private:
80
  ObjectType drop_type_;
81
  PTQualifiedNameListNode::SharedPtr names_;
82
83
  // Set to true for DROP IF EXISTS statements.
84
  bool drop_if_exists_;
85
};
86
87
}  // namespace ql
88
}  // namespace yb
89
90
#endif  // YB_YQL_CQL_QL_PTREE_PT_DROP_H_