MySQL  8.0.27
Source Code Documentation
Replicated_columns_view Class Reference

Since it's not mandatory that all fields in a TABLE object are replicated, this class extends Table_columns_view container and adds logic to filter out not needed columns. More...

#include <log_event.h>

Inheritance diagram for Replicated_columns_view:
Table_columns_view< ExclusionFilter >

Public Types

enum  enum_replication_flow { OUTBOUND , INBOUND }
 
- Public Types inherited from Table_columns_view< ExclusionFilter >
using filter_fn_type = ExclusionFilter
 Alias for the predicate type, for readability purposes. More...
 

Public Member Functions

 Replicated_columns_view (Replicated_columns_view::enum_replication_flow direction, THD const *thd=nullptr)
 Constructor which takes the replication flow direction, meaning, will this object be used to process inbound or outbound replication. More...
 
 Replicated_columns_view (TABLE const *table, Replicated_columns_view::enum_replication_flow direction, THD const *thd=nullptr)
 Constructor which takes the TABLE object whose field set will be iterated. More...
 
 ~Replicated_columns_view () override=default
 Destructor for the class. More...
 
Replicated_columns_viewset_thd (THD const *thd)
 Setter to initialize the THD object instance to be used to determine if filtering is enabled. More...
 
bool is_inbound_filtering_enabled ()
 Returns whether or not filtering should be enabled, given the current THD instance in use. More...
 
bool inbound_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 iteration, when processing inbound replication. More...
 
bool outbound_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 iteration, when processing outbound replication. More...
 
 Replicated_columns_view (const Replicated_columns_view &rhs)=delete
 
 Replicated_columns_view (Replicated_columns_view &&rhs)=delete
 
Replicated_columns_viewoperator= (const Replicated_columns_view &rhs)=delete
 
Replicated_columns_viewoperator= (Replicated_columns_view &&rhs)=delete
 
- Public Member Functions inherited from Table_columns_view< ExclusionFilter >
template<typename U = ExclusionFilter>
 Table_columns_view (unsigned long options=0, typename std::enable_if< std::is_same< U, std::function< bool(TABLE const *, size_t)>>::value >::type *=nullptr)
 Empty constructor, only available when the predicate type is a lambda function. More...
 
template<typename U = ExclusionFilter>
 Table_columns_view (TABLE const *table, unsigned long options=0, typename std::enable_if< std::is_same< U, std::function< bool(TABLE const *, size_t)>>::value >::type *=0)
 Constructor that takes the target TABLE object, only available when the predicate type is a lambda function. More...
 
 Table_columns_view (ExclusionFilter filtering_predicate, unsigned long options=0)
 Constructor which takes a predicate used to filter this container iteration. More...
 
 Table_columns_view (TABLE const *table, ExclusionFilter filtering_predicate, unsigned long options=0)
 Constructor which takes the TABLE object whose field set will be iterated and a predicate used to filter this container iteration. More...
 
virtual ~Table_columns_view ()
 Destructor for the class. More...
 
Table_columns_viewset_table (const TABLE *rhs)
 Setter which initializes the internal reference to the TABLE object whose field set will be iterated over. More...
 
Table_columns_viewset_filter (ExclusionFilter rhs)
 Setter which initializes the internal filtering predicate of type ExclusionFilter. More...
 
 Table_columns_view (const Table_columns_view &rhs)=delete
 
 Table_columns_view (Table_columns_view &&rhs)=delete
 
Table_columns_viewoperator= (const Table_columns_view &rhs)=delete
 
Table_columns_viewoperator= (Table_columns_view &&rhs)=delete
 
size_t absolute_size () const
 Computes the total number of fields in the table. More...
 
size_t filtered_size () const
 Computes the total number of fields after filtering. More...
 
iterator begin ()
 Creates an iterator object, pointing at the beginning of the table field set. More...
 
iterator end ()
 Creates an iterator object, pointing at the end of the table field set. More...
 
bool is_excluded (size_t index) const
 Returns whether or not the field at index is to be excluded from the field set iteration process. More...
 
MY_BITMAPget_included_fields_bitmap ()
 Returns the bitmap for the columns from the local table set that are to be included in the replicated row. More...
 
MY_BITMAPget_excluded_fields_bitmap ()
 Returns the bitmap for the columns from the local table set that are to be excluded from the replicated row. More...
 
Table_columns_viewtranslate_bitmap (MY_BITMAP &source, MY_BITMAP &destination)
 Takes a bitmap object, as received from the replication channel and translates it to a bitmap that matches the local TABLE object. More...
 
size_t translate_position (size_t source)
 Translates a position in the received replicated table into a position in the local table. More...
 
template<typename F >
 Table_columns_view (F filtering_predicate, unsigned long options)
 
template<typename F >
 Table_columns_view (TABLE const *target, F filtering_predicate, unsigned long options)
 

Private Attributes

THD const * m_thd
 Instance of THD class to be used to determine if filtering is to be enabled. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Table_columns_view< ExclusionFilter >
static constexpr unsigned long DEFAULTS = 0
 Default set of options. More...
 
static constexpr unsigned long VFIELDS_ONLY = 1
 Request the view excluding filter to operate TABLE::vfields instead of the full set. More...
 
- Protected Member Functions inherited from Table_columns_view< ExclusionFilter >
Table_columns_viewinit_fields_bitmaps ()
 Initializes the internal included and excluded fields bitmaps. More...
 

Detailed Description

Since it's not mandatory that all fields in a TABLE object are replicated, this class extends Table_columns_view container and adds logic to filter out not needed columns.

One active use-case relates to hidden generated columns. These type of columns are used to support functional indexes and are not meant to be replicated nor included in the serialization/deserialization of binlog events. Moreover, since hidden generated columns are always placed at the end of the field set, replication would break for cases where slaves have extra columns, if they were not excluded from replication:

 MASTER TABLE `t`                SLAVE TABLE `t`
 +----+----+----+------+------+  +----+----+----+-----+------+------+
 | C1 | C2 | C3 | HGC1 | HGC2 |  | C1 | C2 | C3 | EC1 | HGC1 | HGC2 |
 +----+----+----+------+------+  +----+----+----+-----+------+------+

In the above example, the extra column EC1 in the slave will be paired with the hidden generated column HGC1 of the master, if hidden generated columns were to be replicated. With filtering enabled for hidden generated columns, applier will observe the columns as follows:

 MASTER TABLE `t`                SLAVE TABLE `t`
 +----+----+----+                +----+----+----+-----+
 | C1 | C2 | C3 |                | C1 | C2 | C3 | EC1 |
 +----+----+----+                +----+----+----+-----+

Member Enumeration Documentation

◆ enum_replication_flow

Enumerator
OUTBOUND 
INBOUND 

Constructor & Destructor Documentation

◆ Replicated_columns_view() [1/4]

Replicated_columns_view::Replicated_columns_view ( Replicated_columns_view::enum_replication_flow  direction,
THD const *  thd = nullptr 
)

Constructor which takes the replication flow direction, meaning, will this object be used to process inbound or outbound replication.

Prints a "session_var=value" string.

Parameters
directionthe replication flow direction for the events being processed, to determine which fields to filter out.
thdinstance of THD class to be used to determine if filtering is to be enabled. It may be nullptr.

Used by mysqlbinlog to print some SET commands just before it prints a query.

◆ Replicated_columns_view() [2/4]

Replicated_columns_view::Replicated_columns_view ( TABLE const *  table,
Replicated_columns_view::enum_replication_flow  direction,
THD const *  thd = nullptr 
)

Constructor which takes the TABLE object whose field set will be iterated.

Parameters
tablereference to the target TABLE object.
directionthe replication flow direction for the events being processed, to determine which fields to filter out.
thdinstance of THD class to be used to determine if filtering is to be enabled. It may be nullptr.

◆ ~Replicated_columns_view()

Replicated_columns_view::~Replicated_columns_view ( )
overridedefault

Destructor for the class.

◆ Replicated_columns_view() [3/4]

Replicated_columns_view::Replicated_columns_view ( const Replicated_columns_view rhs)
delete

◆ Replicated_columns_view() [4/4]

Replicated_columns_view::Replicated_columns_view ( Replicated_columns_view &&  rhs)
delete

Member Function Documentation

◆ inbound_filtering()

bool Replicated_columns_view::inbound_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 iteration, when processing inbound replication.

Parameters
tablereference to the target TABLE object.
column_indexindex for the column to be tested for filtering,
Returns
true if the field is to be filtered out and false otherwise.

◆ is_inbound_filtering_enabled()

bool Replicated_columns_view::is_inbound_filtering_enabled ( )

Returns whether or not filtering should be enabled, given the current THD instance in use.

Currently, filtering is enabled for inbound replication if the source of replication is a server with version higher than 8.0.17.

Returns
true if filtering should be enabled and false otherwise.

◆ operator=() [1/2]

Replicated_columns_view& Replicated_columns_view::operator= ( const Replicated_columns_view rhs)
delete

◆ operator=() [2/2]

Replicated_columns_view& Replicated_columns_view::operator= ( Replicated_columns_view &&  rhs)
delete

◆ outbound_filtering()

bool Replicated_columns_view::outbound_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 iteration, when processing outbound replication.

Parameters
tablereference to the target TABLE object.
column_indexindex for the column to be tested for filtering,
Returns
true if the field is to be filtered out and false otherwise.

◆ set_thd()

Replicated_columns_view & Replicated_columns_view::set_thd ( THD const *  thd)

Setter to initialize the THD object instance to be used to determine if filtering is enabled.

Parameters
thdinstance of THD class to be used to determine if filtering is to be enabled. It may be nullptr.
Returns
this object reference (for chaining purposes).

Member Data Documentation

◆ m_thd

THD const* Replicated_columns_view::m_thd
private

Instance of THD class to be used to determine if filtering is to be enabled.


The documentation for this class was generated from the following files: