MySQL  8.0.17
Source Code Documentation
rpl_utility.cc File Reference
#include "sql/rpl_utility.h"
#include <string.h>
#include <iterator>
#include <new>
#include <utility>
#include "binary_log_funcs.h"
#include "lex_string.h"
#include "my_byteorder.h"
#include "my_dbug.h"
#include "my_loglevel.h"
#include "my_sys.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/service_mysql_alloc.h"
#include "sql/thr_malloc.h"
#include <algorithm>
#include "binlog_event.h"
#include "m_ctype.h"
#include "m_string.h"
#include "my_base.h"
#include "my_bitmap.h"
#include "mysql/psi/psi_memory.h"
#include "mysqld_error.h"
#include "sql/create_field.h"
#include "sql/dd/dd.h"
#include "sql/dd/dictionary.h"
#include "sql/derror.h"
#include "sql/field.h"
#include "sql/log.h"
#include "sql/log_event.h"
#include "sql/my_decimal.h"
#include "sql/mysqld.h"
#include "sql/psi_memory_key.h"
#include "sql/rpl_rli.h"
#include "sql/rpl_slave.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_list.h"
#include "sql/sql_plugin_ref.h"
#include "sql/sql_tmp_table.h"
#include "sql_show.h"
#include "sql_string.h"
#include "template_utils.h"
#include "typelib.h"

Macros

#define HASH_ROWS_POS_SEARCH_INVALID   -1
 

Functions

static int compare (size_t a, size_t b)
 Function to compare two size_t integers for their relative order. More...
 
static int compare_lengths (Field *field, enum_field_types source_type, uint16 metadata)
 
static bool is_conversion_ok (int order)
 Check the order variable and print errors if the order is not acceptable according to the current settings. More...
 
bool timestamp_cross_check (enum_field_types type1, enum_field_types type2)
 Check if the types are criss cross means type1 is MYSQL_TYPE_TIMESTAMP and type2 as MYSQL_TYPE_TIMESTAMP2 or vice versa. More...
 
bool datetime_cross_check (enum_field_types type1, enum_field_types type2)
 Check if the types are criss cross means type1 is MYSQL_TYPE_DATETIME and type2 as MYSQL_TYPE_DATETIME or vice versa. More...
 
bool time_cross_check (enum_field_types type1, enum_field_types type2)
 Check if the types are criss cross means type1 is MYSQL_TYPE_TIME and type2 as MYSQL_TYPE_TIME2 or vice versa. More...
 
static bool can_convert_field_to (Field *field, enum_field_types source_type, uint metadata, bool is_array, Relay_log_info *rli, uint16 mflags, int *order_var)
 Can a type potentially be converted to another type? More...
 
std::pair< my_off_t, std::pair< uint, bool > > read_field_metadata (const uchar *buffer, enum_field_types binlog_type)
 Decode field metadata from a char buffer (serialized form) into an int (packed form). More...
 

Variables

PSI_memory_key key_memory_table_def_memory
 

Macro Definition Documentation

◆ HASH_ROWS_POS_SEARCH_INVALID

#define HASH_ROWS_POS_SEARCH_INVALID   -1

Function Documentation

◆ can_convert_field_to()

static bool can_convert_field_to ( Field field,
enum_field_types  source_type,
uint  metadata,
bool  is_array,
Relay_log_info rli,
uint16  mflags,
int *  order_var 
)
static

Can a type potentially be converted to another type?

This function check if the types are convertible and what conversion is required.

If conversion is not possible, and error is printed.

If conversion is possible:

  • *order will be set to -1 if source type is smaller than target type and a non-lossy conversion can be required. This includes the case where the field types are different but types could actually be converted in either direction.
  • *order will be set to 0 if no conversion is required.
  • *order will be set to 1 if the source type is strictly larger than the target type and that conversion is potentially lossy.
Parameters
[in]fieldTarget field
[in]source_typeSource field type
[in]metadataSource field metadata
[in]is_arrayWhether the source field is a typed array
[in]rliRelay log info (for error reporting)
[in]mflagsFlags from the table map event
[out]order_varOrder between source field and target field
Returns
true if conversion is possible according to the current settings, false if conversion is not possible according to the current setting.

◆ compare()

static int compare ( size_t  a,
size_t  b 
)
static

Function to compare two size_t integers for their relative order.

Used below.

◆ compare_lengths()

static int compare_lengths ( Field field,
enum_field_types  source_type,
uint16  metadata 
)
static

◆ datetime_cross_check()

bool datetime_cross_check ( enum_field_types  type1,
enum_field_types  type2 
)
inline

Check if the types are criss cross means type1 is MYSQL_TYPE_DATETIME and type2 as MYSQL_TYPE_DATETIME or vice versa.

◆ is_conversion_ok()

static bool is_conversion_ok ( int  order)
static

Check the order variable and print errors if the order is not acceptable according to the current settings.

Parameters
orderThe computed order of the conversion needed.

◆ read_field_metadata()

std::pair<my_off_t, std::pair<uint, bool> > read_field_metadata ( const uchar buffer,
enum_field_types  binlog_type 
)

Decode field metadata from a char buffer (serialized form) into an int (packed form).

Note
On little-endian platforms (e.g Intel) this function effectively inverts order of bytes compared to what Field::save_field_metadata() writes. E.g for MYSQL_TYPE_NEWDECIMAL save_field_metadata writes precision into the first byte and decimals into the second, this function puts precision into the second byte and decimals into the first. This layout is expected by replication code that reads metadata in the uint form. Due to this design feature show_sql_type() can't correctly print immediate output of save_field_metadata(), this function have to be used as translator.
Parameters
bufferField metadata, in the character stream form produced by save_field_metadata.
binlog_typeThe type of the field, in the form returned by Field::binlog_type and stored in Table_map_log_event.
Return values
pairwhere:
  • the first component is the length of the metadata within 'buffer', i.e., how much the buffer pointer should move forward in order to skip it.
  • the second component is pair containing:
    • the metadata, encoded as an 'uint', in the form required by e.g. show_sql_type.
    • bool indicating whether the field is array (true) or a scalar (false)

◆ time_cross_check()

bool time_cross_check ( enum_field_types  type1,
enum_field_types  type2 
)
inline

Check if the types are criss cross means type1 is MYSQL_TYPE_TIME and type2 as MYSQL_TYPE_TIME2 or vice versa.

◆ timestamp_cross_check()

bool timestamp_cross_check ( enum_field_types  type1,
enum_field_types  type2 
)
inline

Check if the types are criss cross means type1 is MYSQL_TYPE_TIMESTAMP and type2 as MYSQL_TYPE_TIMESTAMP2 or vice versa.

Variable Documentation

◆ key_memory_table_def_memory

PSI_memory_key key_memory_table_def_memory