MySQL 9.1.0
Source Code Documentation
replicated_columns_view.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 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 RPL_REPLICATED_COLUMNS_VIEW_H
25#define RPL_REPLICATED_COLUMNS_VIEW_H
26
28#include "sql/rpl_utility.h" // table_def
29#include "sql/table_column_iterator.h" // Table_columns_view::iterator
30
31namespace cs {
32namespace util {
33/**
34 @class ReplicatedColumnsView
35
36 Since it's not mandatory that all fields in a TABLE object are replicated,
37 this class extends Table_columns_view container and adds logic to filter out
38 not needed columns.
39
40 One active use-case relates to hidden generated columns. These type of
41 columns are used to support functional indexes and are not meant to be
42 replicated nor included in the serialization/deserialization of binlog
43 events.
44 @see ColumnFilterInboundFunctionalIndexes
45 @see ColumnFilterOutboundFunctionalIndexes
46
47 Another case relates to GIPKs, where the source or replica might contain a
48 generated primary key that does not exist on the other side of the stream.
49 In cases of differences in GIPK, the columns should be filtered out
50 @see ColumnFilterInboundGipk
51
52 This class allows for the use of other filters that can be added at any point.
53 */
55 public:
56 /**
57 Constructor for table iteration where a table and filters can be configured
58
59 @param thd instance of `THD` class to be used to determine if filtering is
60 to be enabled in some cases. It may be `nullptr`.
61 */
62 ReplicatedColumnsView(THD const *thd = nullptr);
63 /**
64 Constructor which takes the TABLE object whose field set will be iterated.
65
66 @param table reference to the target TABLE object.
67 @param thd instance of `THD` class to be used to determine if filtering is
68 to be enabled. It may be `nullptr`.
69 */
70 ReplicatedColumnsView(TABLE const *table, THD const *thd = nullptr);
71 /**
72 Destructor for the class.
73 */
74 ~ReplicatedColumnsView() override = default;
75 /**
76 Setter to initialize the `THD` object instance to be used to determine if
77 filtering is enabled.
78
79 @param thd instance of `THD` class to be used to determine if filtering is
80 to be enabled. It may be `nullptr`.
81
82 @return this object reference (for chaining purposes).
83 */
85
86 /**
87 Returns whether or not the field of table `table` at `column_index` is to be
88 filtered from this container iteration, according to the list of filters
89
90 @param table reference to the target TABLE object.
91 @param column_index index for the column to be tested for filtering,
92
93 @return true if the field is to be filtered out and false otherwise.
94 */
95 virtual bool execute_filtering(TABLE const *table, size_t column_index);
96
97 /**
98 Adds a new filter according to the given type
99
100 @param filter_type the filter type to be added to this column view
101 */
103
104 /**
105 @brief adds a new filter if the filter's static member function
106 is_filter_needed returns true
107
108 @param thd the THD with context on the situation
109 @param table the table being iterated
110 @param tabledef the replicated table context if applicable
111 @param filter_type the filter type to be added
112 */
114 THD const &thd, TABLE *table, table_def const *tabledef,
116
117 // --> Deleted constructors and methods to remove default move/copy semantics
122 // <--
123
124 private:
125 /**
126 Instance of `THD` class to be used to determine if filtering is to be
127 enabled.
128 */
129 THD const *m_thd;
130
131 /** List of filters to be used against the list of fields */
132 std::vector<std::unique_ptr<cs::util::ColumnFilter>> m_filters;
133};
134} // namespace util
135} // namespace cs
136
137#endif // RPL_REPLICATED_COLUMNS_VIEW_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 template class acts as a container of table columns and encapsulates and abstracts a TABLE objec...
Definition: table_column_iterator.h:109
ColumnFilterType
The different types of filters for column iteration.
Definition: column_filter_factory.h:43
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
ReplicatedColumnsView(THD const *thd=nullptr)
Constructor for table iteration where a table and filters can be configured.
Definition: replicated_columns_view.cc:29
THD const * m_thd
Instance of THD class to be used to determine if filtering is to be enabled.
Definition: replicated_columns_view.h:129
ReplicatedColumnsView(const ReplicatedColumnsView &rhs)=delete
ReplicatedColumnsView & operator=(const ReplicatedColumnsView &rhs)=delete
~ReplicatedColumnsView() override=default
Destructor for the class.
std::vector< std::unique_ptr< cs::util::ColumnFilter > > m_filters
List of filters to be used against the list of fields.
Definition: replicated_columns_view.h:132
ReplicatedColumnsView & operator=(ReplicatedColumnsView &&rhs)=delete
virtual bool execute_filtering(TABLE const *table, size_t column_index)
Returns whether or not the field of table table at column_index is to be filtered from this container...
Definition: replicated_columns_view.cc:71
ReplicatedColumnsView(ReplicatedColumnsView &&rhs)=delete
void add_filter_if_needed(THD const &thd, TABLE *table, table_def const *tabledef, cs::util::ColumnFilterFactory::ColumnFilterType filter_type)
adds a new filter if the filter's static member function is_filter_needed returns true
Definition: replicated_columns_view.cc:60
ReplicatedColumnsView & set_thd(THD const *thd)
Setter to initialize the THD object instance to be used to determine if filtering is enabled.
Definition: replicated_columns_view.cc:46
void add_filter(cs::util::ColumnFilterFactory::ColumnFilterType filter_type)
Adds a new filter according to the given type.
Definition: replicated_columns_view.cc:53
A table definition from the master.
Definition: rpl_utility.h:249
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: commit_order_queue.h:34
Definition: table.h:1421