YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/tserver/pg_create_table.h
Line
Count
Source
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#ifndef YB_TSERVER_PG_CREATE_TABLE_H
15
#define YB_TSERVER_PG_CREATE_TABLE_H
16
17
#include "yb/client/client_fwd.h"
18
#include "yb/client/schema.h"
19
#include "yb/client/yb_table_name.h"
20
21
#include "yb/common/common_fwd.h"
22
#include "yb/common/partition.h"
23
#include "yb/common/pg_types.h"
24
25
#include "yb/tserver/pg_client.fwd.h"
26
27
#include "yb/util/monotime.h"
28
#include "yb/util/status_fwd.h"
29
30
namespace yb {
31
namespace tserver {
32
33
class PgCreateTable {
34
 public:
35
  explicit PgCreateTable(const PgCreateTableRequestPB& req);
36
37
  CHECKED_STATUS Prepare();
38
  CHECKED_STATUS Exec(
39
      client::YBClient* client, const TransactionMetadata* transaction_metadata,
40
      CoarseTimePoint deadline);
41
42
1.41k
  const PgObjectId& indexed_table_id() const {
43
1.41k
    return indexed_table_id_;
44
1.41k
  }
45
46
 private:
47
  CHECKED_STATUS AddColumn(const PgCreateColumnPB& req);
48
  void EnsureYBbasectidColumnCreated();
49
  Result<std::vector<std::string>> BuildSplitRows(const client::YBSchema& schema);
50
51
  size_t PrimaryKeyRangeColumnCount() const;
52
53
  const PgCreateTableRequestPB& req_;
54
  client::YBTableName table_name_;
55
  boost::optional<YBHashSchema> hash_schema_;
56
  std::vector<std::string> range_columns_;
57
  client::YBSchemaBuilder schema_builder_;
58
  PgObjectId indexed_table_id_;
59
  bool ybbasectid_added_ = false;
60
};
61
62
}  // namespace tserver
63
}  // namespace yb
64
65
#endif  // YB_TSERVER_PG_CREATE_TABLE_H