YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/yql/pggate/pg_dml_write.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
#ifndef YB_YQL_PGGATE_PG_DML_WRITE_H_
16
#define YB_YQL_PGGATE_PG_DML_WRITE_H_
17
18
#include "yb/yql/pggate/pg_dml.h"
19
20
namespace yb {
21
namespace pggate {
22
23
//--------------------------------------------------------------------------------------------------
24
// DML WRITE - Insert, Update, Delete.
25
//--------------------------------------------------------------------------------------------------
26
27
class PgDmlWrite : public PgDml {
28
 public:
29
  // Abstract class without constructors.
30
  virtual ~PgDmlWrite();
31
32
  // Prepare write operations.
33
  virtual CHECKED_STATUS Prepare();
34
35
  // Setup internal structures for binding values during prepare.
36
  void PrepareColumns();
37
38
  // force_non_bufferable flag indicates this operation should not be buffered.
39
  CHECKED_STATUS Exec(bool force_non_bufferable = false);
40
41
14
  void SetIsSystemCatalogChange() {
42
14
    write_req_->set_is_ysql_catalog_change(true);
43
14
  }
44
45
7.19M
  void SetCatalogCacheVersion(const uint64_t catalog_cache_version) override {
46
7.19M
    write_req_->set_ysql_catalog_version(catalog_cache_version);
47
7.19M
  }
48
49
19.1k
  int32_t GetRowsAffectedCount() {
50
19.1k
    return rows_affected_count_;
51
19.1k
  }
52
53
  CHECKED_STATUS SetWriteTime(const HybridTime& write_time);
54
55
 protected:
56
  // Constructor.
57
  PgDmlWrite(PgSession::ScopedRefPtr pg_session,
58
             const PgObjectId& table_id,
59
             bool is_single_row_txn = false);
60
61
  // Allocate write request.
62
  void AllocWriteRequest();
63
64
  // Allocate column expression.
65
  PgsqlExpressionPB *AllocColumnBindPB(PgColumn *col) override;
66
67
  // Allocate target for selected or returned expressions.
68
  PgsqlExpressionPB *AllocTargetPB() override;
69
70
  // Allocate protobuf for a qual in the write request's where_clauses list.
71
  PgsqlExpressionPB *AllocQualPB() override;
72
73
  // Allocate protobuf for a column reference in the write request's col_refs list.
74
  PgsqlColRefPB *AllocColRefPB() override;
75
76
  // Clear the write request's col_refs list.
77
  void ClearColRefPBs() override;
78
79
  // Allocate column expression.
80
  PgsqlExpressionPB *AllocColumnAssignPB(PgColumn *col) override;
81
82
  // Protobuf code.
83
  std::shared_ptr<PgsqlWriteRequestPB> write_req_;
84
85
  bool is_single_row_txn_ = false; // default.
86
87
  int32_t rows_affected_count_ = 0;
88
89
 private:
90
  CHECKED_STATUS DeleteEmptyPrimaryBinds();
91
92
  virtual PgsqlWriteRequestPB::PgsqlStmtType stmt_type() const = 0;
93
};
94
95
}  // namespace pggate
96
}  // namespace yb
97
98
#endif // YB_YQL_PGGATE_PG_DML_WRITE_H_