MySQL 8.3.0
Source Code Documentation
replicated_columns_view_factory.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 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 CS_REPLICATED_COLUMNS_VIEW_UTILS_H
24#define CS_REPLICATED_COLUMNS_VIEW_UTILS_H
25
26#include "sql/changestreams/misc/replicated_columns_view.h" // ReplicatedColumnsView
28#include "sql/rpl_utility.h" // tabledef
29#include "sql/sql_gipk.h" // table_has_generated_invisible_primary_key
30
31namespace cs {
32namespace util {
33
34/**
35 @brief This class allows the creation of different types of column view
36 instances and also adds different filters depending on context.
37*/
39 public:
40 /**
41 This function returns the appropriate class to iterate over the given
42 table columns. It also adds inbound filtering
43
44 It might return a standard column view/iteration class or one that
45 accounts for GIPK or other differences
46
47 @param thd The thread object to extract context information
48 @param table The table where the column view will be created
49 @param tabledef Context on the replicated table
50
51 @return A unique pointer to a ReplicatedColumnsView object instance
52 */
53 static std::unique_ptr<ReplicatedColumnsView>
55 table_def const *tabledef) {
56 std::unique_ptr<ReplicatedColumnsView> column_view;
57
58 bool source_has_gipk =
59 tabledef && tabledef->is_gipk_present_on_source_table();
60 bool replica_has_gipk =
62
63 if (!replica_has_gipk && source_has_gipk)
64 column_view = std::unique_ptr<cs::util::ReplicatedColumnsView>{
66 else
67 column_view = std::unique_ptr<cs::util::ReplicatedColumnsView>{
69
70 column_view->add_filter_if_needed(
71 *thd, table, tabledef,
73 column_view->add_filter_if_needed(
74 *thd, table, tabledef,
76
77 return column_view;
78 }
79
80 /**
81 This function returns the appropriate class to iterate over the given
82 table columns. It also adds outbound filtering
83
84 @param thd The thread object to extract context information
85 @param table The table where the column view will be created
86
87 @return A unique pointer to a ReplicatedColumnsView object instance
88 */
89 static std::unique_ptr<ReplicatedColumnsView>
91 auto column_view = std::unique_ptr<cs::util::ReplicatedColumnsView>{
93
94 column_view->add_filter_if_needed(
95 *thd, table, nullptr,
97
98 return column_view;
99 }
100};
101} // namespace util
102} // namespace cs
103#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:35
This class allows the creation of different types of column view instances and also adds different fi...
Definition: replicated_columns_view_factory.h:38
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:90
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:54
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:51
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
A table definition from the master.
Definition: rpl_utility.h:247
bool is_gipk_present_on_source_table() const
Checks if the table contains a GIPK.
Definition: rpl_utility.cc:787
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
Definition: commit_order_queue.h:33
bool table_has_generated_invisible_primary_key(const TABLE *table)
Check if table has a generated invisible primary key.
Definition: sql_gipk.cc:495
Definition: table.h:1403