MySQL 8.2.0
Source Code Documentation
replicated_columns_view.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef RPL_REPLICATED_COLUMNS_VIEW_H
24#define RPL_REPLICATED_COLUMNS_VIEW_H
25
27#include "sql/rpl_utility.h" // table_def
28#include "sql/table_column_iterator.h" // Table_columns_view::iterator
29
30namespace cs {
31namespace util {
32/**
33 @class ReplicatedColumnsView
34
35 Since it's not mandatory that all fields in a TABLE object are replicated,
36 this class extends Table_columns_view container and adds logic to filter out
37 not needed columns.
38
39 One active use-case relates to hidden generated columns. These type of
40 columns are used to support functional indexes and are not meant to be
41 replicated nor included in the serialization/deserialization of binlog
42 events.
43 @see ColumnFilterInboundFunctionalIndexes
44 @see ColumnFilterOutboundFunctionalIndexes
45
46 Another case relates to GIPKs, where the source or replica might contain a
47 generated primary key that does not exist on the other side of the stream.
48 In cases of differences in GIPK, the columns should be filtered out
49 @see ColumnFilterInboundGipk
50
51 This class allows for the use of other filters that can be added at any point.
52 */
54 public:
55 /**
56 Constructor for table iteration where a table and filters can be configured
57
58 @param thd instance of `THD` class to be used to determine if filtering is
59 to be enabled in some cases. It may be `nullptr`.
60 */
61 ReplicatedColumnsView(THD const *thd = nullptr);
62 /**
63 Constructor which takes the TABLE object whose field set will be iterated.
64
65 @param table reference to the target TABLE object.
66 @param thd instance of `THD` class to be used to determine if filtering is
67 to be enabled. It may be `nullptr`.
68 */
69 ReplicatedColumnsView(TABLE const *table, THD const *thd = nullptr);
70 /**
71 Destructor for the class.
72 */
73 ~ReplicatedColumnsView() override = default;
74 /**
75 Setter to initialize the `THD` object instance to be used to determine if
76 filtering is enabled.
77
78 @param thd instance of `THD` class to be used to determine if filtering is
79 to be enabled. It may be `nullptr`.
80
81 @return this object reference (for chaining purposes).
82 */
84
85 /**
86 Returns whether or not the field of table `table` at `column_index` is to be
87 filtered from this container iteration, according to the list of filters
88
89 @param table reference to the target TABLE object.
90 @param column_index index for the column to be tested for filtering,
91
92 @return true if the field is to be filtered out and false otherwise.
93 */
94 virtual bool execute_filtering(TABLE const *table, size_t column_index);
95
96 /**
97 Adds a new filter according to the given type
98
99 @param filter_type the filter type to be added to this column view
100 */
102
103 /**
104 @brief adds a new filter if the filter's static member function
105 is_filter_needed returns true
106
107 @param thd the THD with context on the situation
108 @param table the table being iterated
109 @param tabledef the replicated table context if applicable
110 @param filter_type the filter type to be added
111 */
113 THD const &thd, TABLE *table, table_def const *tabledef,
115
116 // --> Deleted constructors and methods to remove default move/copy semantics
121 // <--
122
123 private:
124 /**
125 Instance of `THD` class to be used to determine if filtering is to be
126 enabled.
127 */
128 THD const *m_thd;
129
130 /** List of filters to be used against the list of fields */
131 std::vector<std::unique_ptr<cs::util::ColumnFilter>> m_filters;
132};
133} // namespace util
134} // namespace cs
135
136#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:35
This template class acts as a container of table columns and encapsulates and abstracts a TABLE objec...
Definition: table_column_iterator.h:108
ColumnFilterType
The different types of filters for column iteration.
Definition: column_filter_factory.h:42
Since it's not mandatory that all fields in a TABLE object are replicated, this class extends Table_c...
Definition: replicated_columns_view.h:53
ReplicatedColumnsView(THD const *thd=nullptr)
Constructor for table iteration where a table and filters can be configured.
Definition: replicated_columns_view.cc:28
THD const * m_thd
Instance of THD class to be used to determine if filtering is to be enabled.
Definition: replicated_columns_view.h:128
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:131
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:70
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:59
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:45
void add_filter(cs::util::ColumnFilterFactory::ColumnFilterType filter_type)
Adds a new filter according to the given type.
Definition: replicated_columns_view.cc:52
A table definition from the master.
Definition: rpl_utility.h:247
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
Definition: commit_order_queue.h:33
Definition: table.h:1396