MySQL 9.1.0
Source Code Documentation
table_def Class Reference

A table definition from the master. More...

#include <rpl_utility.h>

Public Member Functions

 table_def ()=default
 No-op constructor. More...
 
 table_def (unsigned char *types, ulong size, uchar *field_metadata, int metadata_size, uchar *null_bitmap, uint16 flags, const std::vector< unsigned int > &vector_dimensionality)
 Constructor. More...
 
 ~table_def ()
 
ulong size () const
 Return the number of fields there is type data for. More...
 
ulong filtered_size (bool replica_has_gipk) const
 Return the number of fields there is type data for minus the GIPK field if this field does not exist in the replica. More...
 
enum_field_types binlog_type (ulong index) const
 
int json_column_count () const
 Return the number of JSON columns in this table. More...
 
enum_field_types type (ulong index) const
 
uint field_metadata (uint index) const
 
bool is_array (uint index) const
 Returns whether or not the field at index is a typed array. More...
 
bool maybe_null (uint index) const
 
uint32 calc_field_size (uint col, const uchar *master_data) const
 
std::vector< unsignedint >::const_iterator get_vector_dimensionality_begin () const
 
std::vector< unsignedint >::const_iterator get_vector_dimensionality_end () const
 
bool compatible_with (THD *thd, Relay_log_info *rli, TABLE *table, TABLE **conv_table_var)
 Decide if the table definition is compatible with a table. More...
 
TABLEcreate_conversion_table (THD *thd, Relay_log_info *rli, TABLE *target_table, bool replica_has_gipk) const
 Create a virtual in-memory temporary table structure. More...
 
bool compute_source_table_gipk_info (THD &thd, TABLE *table)
 Evaluates if the source table might contain a GIPK. More...
 
bool is_gipk_present_on_source_table () const
 Checks if the table contains a GIPK. More...
 

Static Public Member Functions

static uint vector_column_count (const unsigned char *types, ulong size)
 Return the number of VECTOR columns. More...
 

Private Attributes

ulong m_size
 
unsigned char * m_type
 
uint m_field_metadata_size
 
uint * m_field_metadata
 
ucharm_null_bits
 
uint16 m_flags
 
ucharm_memory
 
int m_json_column_count
 
bool * m_is_array
 
bool m_is_gipk_set
 
bool m_is_gipk_on_table
 
std::vector< unsigned int > m_vector_dimensionality
 

Detailed Description

A table definition from the master.

The responsibilities of this class is:

  • Extract and decode table definition data from the table map event
  • Check if table definition in table map is compatible with table definition on slave
  • expose the type information so that it can be used when encoding or decoding row event data.

Constructor & Destructor Documentation

◆ table_def() [1/2]

table_def::table_def ( )
default

No-op constructor.

Instances of RPL_Table_ref are created by first allocating memory, then placement-new-ing an RPL_Table_ref object containing an uninitialized table_def object which is only conditionally initialized. See Table_map_log_event::do_apply_event().

◆ table_def() [2/2]

table_def::table_def ( unsigned char *  types,
ulong  size,
uchar field_metadata,
int  metadata_size,
uchar null_bitmap,
uint16  flags,
const std::vector< unsigned int > &  vector_dimensionality 
)

Constructor.

Parameters
typesArray of types, each stored as a byte
sizeNumber of elements in array 'types'
field_metadataArray of extra information about fields
metadata_sizeSize of the field_metadata array
null_bitmapThe bitmap of fields that can be null
flagsTable flags
vector_dimensionalityVector dimensionality array

◆ ~table_def()

table_def::~table_def ( )

Member Function Documentation

◆ binlog_type()

enum_field_types table_def::binlog_type ( ulong  index) const
inline

◆ calc_field_size()

uint32 table_def::calc_field_size ( uint  col,
const uchar master_data 
) const

◆ compatible_with()

bool table_def::compatible_with ( THD thd,
Relay_log_info rli,
TABLE table,
TABLE **  conv_table_var 
)

Decide if the table definition is compatible with a table.

Is the definition compatible with a table when it does not belong to the data dictionary?

Compare the definition with a table to see if it is compatible with it.

A table definition is compatible with a table if:

  • The columns types of the table definition is a (not necessarily proper) prefix of the column type of the table.
  • The other way around.
  • Each column on the master that also exists on the slave can be converted according to the current settings of REPLICA_TYPE_CONVERSIONS.
Parameters
thdCurrent thread
rliPointer to relay log info
tablePointer to table to compare with.
[out]conv_table_varPointer to temporary table for holding conversion table.
Return values
1if the table definition is not compatible with table
0if the table definition is compatible with table

This function first finds out whether the table belongs to the data dictionary. When not, it will compare the master table with an existing table on the slave and see if they are compatible with respect to the current settings of REPLICA_TYPE_CONVERSIONS.

If the tables are compatible and conversions are required, tmp_table_var will be set to a virtual temporary table with field pointers for the fields that require conversions. This allow simple checking of whether a conversion are to be applied or not.

If tables are compatible, but no conversions are necessary, tmp_table_var will be set to NULL.

Parameters
[in]rliRelay log info, for error reporting.
[in]tableTable to compare with
[out]conv_table_varVirtual temporary table for performing conversions, if necessary.
Return values
trueMaster table is compatible with slave table.
falseWhen the table belongs to the data dictionary or master table is not compatible with slave table.

◆ compute_source_table_gipk_info()

bool table_def::compute_source_table_gipk_info ( THD thd,
TABLE table 
)

Evaluates if the source table might contain a GIPK.

Note
for servers of older versions that do not fully support GIPK, this sets the info that is a guess based on available information replication has.

In the case when the replica has a GIPK, the source is from an old version that does not indicate if it has a GIPK or not, and the source either has extra columns, or the replica has two more more extra columns true is returned. This function does not report an error.

Parameters
thdThe thread object associated to the application
tableThe table in the replica.
Returns
true if this table definition is found to be incompatible with the table, false otherwise.

◆ create_conversion_table()

TABLE * table_def::create_conversion_table ( THD thd,
Relay_log_info rli,
TABLE target_table,
bool  replica_has_gipk 
) const

Create a virtual in-memory temporary table structure.

Create a conversion table.

The table structure has records and field array so that a row can be unpacked into the record for further processing.

In the virtual table, each field that requires conversion will have a non-NULL value, while fields that do not require conversion will have a NULL value.

Some information that is missing in the events, such as the character set for string types, are taken from the table that the field is going to be pushed into, so the target table that the data eventually need to be pushed into need to be supplied.

Parameters
thdThread to allocate memory from.
rliRelay log info structure, for error reporting.
target_tableTarget table for fields.
replica_has_gipkDoes the replica table contain a GIPK
Returns
A pointer to a temporary table with memory allocated in the thread's memroot, NULL if the table could not be created

If the function is unable to create the conversion table, an error will be printed and NULL will be returned.

Returns
Pointer to conversion table, or NULL if unable to create conversion table.

◆ field_metadata()

uint table_def::field_metadata ( uint  index) const
inline

◆ filtered_size()

ulong table_def::filtered_size ( bool  replica_has_gipk) const
inline

Return the number of fields there is type data for minus the GIPK field if this field does not exist in the replica.

Returns
The number of fields there is a type minus the GIPK

◆ get_vector_dimensionality_begin()

std::vector< unsignedint >::const_iterator table_def::get_vector_dimensionality_begin ( ) const
inline

◆ get_vector_dimensionality_end()

std::vector< unsignedint >::const_iterator table_def::get_vector_dimensionality_end ( ) const
inline

◆ is_array()

bool table_def::is_array ( uint  index) const
inline

Returns whether or not the field at index is a typed array.

◆ is_gipk_present_on_source_table()

bool table_def::is_gipk_present_on_source_table ( ) const

Checks if the table contains a GIPK.

Note
for servers of older versions that do not fully support GIPK, this method returns a guess based on available information replication has.
Returns
true if we believe the table to contain a GIPK, false otherwise

◆ json_column_count()

int table_def::json_column_count ( ) const
inline

Return the number of JSON columns in this table.

◆ maybe_null()

bool table_def::maybe_null ( uint  index) const
inline

◆ size()

ulong table_def::size ( ) const
inline

Return the number of fields there is type data for.

Returns
The number of fields that there is type data for.

◆ type()

enum_field_types table_def::type ( ulong  index) const
inline

◆ vector_column_count()

static uint table_def::vector_column_count ( const unsigned char *  types,
ulong  size 
)
inlinestatic

Return the number of VECTOR columns.

Member Data Documentation

◆ m_field_metadata

uint* table_def::m_field_metadata
private

◆ m_field_metadata_size

uint table_def::m_field_metadata_size
private

◆ m_flags

uint16 table_def::m_flags
private

◆ m_is_array

bool* table_def::m_is_array
private

◆ m_is_gipk_on_table

bool table_def::m_is_gipk_on_table
private

◆ m_is_gipk_set

bool table_def::m_is_gipk_set
private

◆ m_json_column_count

int table_def::m_json_column_count
mutableprivate

◆ m_memory

uchar* table_def::m_memory
private

◆ m_null_bits

uchar* table_def::m_null_bits
private

◆ m_size

ulong table_def::m_size
private

◆ m_type

unsigned char* table_def::m_type
private

◆ m_vector_dimensionality

std::vector<unsigned int> table_def::m_vector_dimensionality
private

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