MySQL 8.4.2
Source Code Documentation
replicated_columns_view_factory.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef CS_REPLICATED_COLUMNS_VIEW_UTILS_H
25#define CS_REPLICATED_COLUMNS_VIEW_UTILS_H
26
27#include "sql/changestreams/misc/replicated_columns_view.h" // ReplicatedColumnsView
29#include "sql/rpl_utility.h" // tabledef
30#include "sql/sql_gipk.h" // table_has_generated_invisible_primary_key
31
32namespace cs {
33namespace util {
34
35/**
36 @brief This class allows the creation of different types of column view
37 instances and also adds different filters depending on context.
38*/
40 public:
41 /**
42 This function returns the appropriate class to iterate over the given
43 table columns. It also adds inbound filtering
44
45 It might return a standard column view/iteration class or one that
46 accounts for GIPK or other differences
47
48 @param thd The thread object to extract context information
49 @param table The table where the column view will be created
50 @param tabledef Context on the replicated table
51
52 @return A unique pointer to a ReplicatedColumnsView object instance
53 */
54 static std::unique_ptr<ReplicatedColumnsView>
56 table_def const *tabledef) {
57 std::unique_ptr<ReplicatedColumnsView> column_view;
58
59 bool source_has_gipk =
60 tabledef && tabledef->is_gipk_present_on_source_table();
61 bool replica_has_gipk =
63
64 if (!replica_has_gipk && source_has_gipk)
65 column_view = std::unique_ptr<cs::util::ReplicatedColumnsView>{
67 else
68 column_view = std::unique_ptr<cs::util::ReplicatedColumnsView>{
70
71 column_view->add_filter_if_needed(
72 *thd, table, tabledef,
74 column_view->add_filter_if_needed(
75 *thd, table, tabledef,
77
78 return column_view;
79 }
80
81 /**
82 This function returns the appropriate class to iterate over the given
83 table columns. It also adds outbound filtering
84
85 @param thd The thread object to extract context information
86 @param table The table where the column view will be created
87
88 @return A unique pointer to a ReplicatedColumnsView object instance
89 */
90 static std::unique_ptr<ReplicatedColumnsView>
92 auto column_view = std::unique_ptr<cs::util::ReplicatedColumnsView>{
94
95 column_view->add_filter_if_needed(
96 *thd, table, nullptr,
98
99 return column_view;
100 }
101};
102} // namespace util
103} // namespace cs
104#endif // CS_REPLICATED_COLUMNS_VIEW_UTILS_H
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
This class allows the creation of different types of column view instances and also adds different fi...
Definition: replicated_columns_view_factory.h:39
static std::unique_ptr< ReplicatedColumnsView > get_columns_view_with_outbound_filters(THD *thd, TABLE *table)
This function returns the appropriate class to iterate over the given table columns.
Definition: replicated_columns_view_factory.h:91
static std::unique_ptr< ReplicatedColumnsView > get_columns_view_with_inbound_filters(THD *thd, TABLE *table, table_def const *tabledef)
This function returns the appropriate class to iterate over the given table columns.
Definition: replicated_columns_view_factory.h:55
Class used when we want a column view over a table in a context where the replicated table contains a...
Definition: replicated_columns_view_with_gipk_on_source.h:52
Since it's not mandatory that all fields in a TABLE object are replicated, this class extends Table_c...
Definition: replicated_columns_view.h:54
A table definition from the master.
Definition: rpl_utility.h:248
bool is_gipk_present_on_source_table() const
Checks if the table contains a GIPK.
Definition: rpl_utility.cc:788
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: commit_order_queue.h:34
bool table_has_generated_invisible_primary_key(const TABLE *table)
Check if table has a generated invisible primary key.
Definition: sql_gipk.cc:496
Definition: table.h:1406