-
Notifications
You must be signed in to change notification settings - Fork 1k
/
master_xcluster_util.cc
66 lines (54 loc) · 2.15 KB
/
master_xcluster_util.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) YugabyteDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations
// under the License.
//
#include "yb/master/xcluster/master_xcluster_util.h"
#include "yb/common/common_types.pb.h"
#include "yb/master/catalog_entity_info.h"
namespace yb::master {
bool IsTableEligibleForXClusterReplication(const master::TableInfo& table) {
if (table.GetTableType() != PGSQL_TABLE_TYPE || table.is_system()) {
// DB Scoped replication Limited to ysql databases.
// System tables are not replicated. DDLs statements will be replicated and executed on the
// target universe to handle catalog changes.
return false;
}
if (table.IsColocationParentTable()) {
// The colocated parent table needs to be replicated.
return true;
}
if (table.is_matview()) {
// Materialized views need not be replicated, since they are not modified. Every time the view
// is refreshed, new tablets are created. The same refresh can just run on the target universe.
return false;
}
if (table.IsColocatedUserTable()) {
// Only the colocated parent table needs to be replicated.
return false;
}
if (table.IsSequencesSystemTable()) {
// xCluster does not yet support replication of sequences.
return false;
}
if (table.IsXClusterDDLReplicationReplicatedDDLsTable()) {
// replicated_ddls is only used on the target, so we do not want to replicate it.
return false;
}
return true;
}
std::string GetFullTableName(const TableInfo& table_info) {
const auto& schema_name = table_info.pgschema_name();
if (schema_name.empty()) {
return table_info.name();
}
return Format("$0.$1", schema_name, table_info.name());
}
} // namespace yb::master