MySQL 9.1.0
Source Code Documentation
rpl_utility.h File Reference
#include <sys/types.h>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <vector>
#include "field_types.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_macros.h"
#include "sql/psi_memory_key.h"
#include <memory>
#include "map_helpers.h"
#include "prealloced_array.h"
#include "sql/table.h"

Go to the source code of this file.

Classes

struct  HASH_ROW_POS
 Hash table used when applying row events on the slave and there is no index on the slave's table. More...
 
struct  hash_slave_rows_free_entry
 
struct  HASH_ROW_PREAMBLE
 Internal structure that acts as a preamble for HASH_ROW_POS in memory structure. More...
 
struct  HASH_ROW_ENTRY
 
class  Hash_slave_rows
 
class  table_def
 A table definition from the master. More...
 
struct  RPL_Table_ref
 Extend the normal Table_ref with a few new fields needed by the slave thread, but nowhere else. More...
 
class  Deferred_log_events
 
class  THD_instance_guard
 Sentry class for managing the need to create and dispose of a local THD instance. More...
 

Macros

#define DBUG_PRINT_BITSET(N, FRM, BS)
 

Functions

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...
 
std::string replace_all_in_str (std::string from, std::string find, std::string replace)
 Replaces every occurrence of the string find by the string replace, within the string from and return the resulting string. More...
 
bool is_require_row_format_violation (const THD *thd)
 This method shall evaluate if a command being executed goes against any of the restrictions of server variable session.require_row_format. More...
 
bool is_immediate_server_gipk_ready (THD &thd)
 Checks if the immediate_server_version supports GIPKs or not. More...
 
bool does_source_table_contain_gipk (Relay_log_info const *rli, TABLE *table)
 Returns if the replicated table contains a GIPK or not. More...
 
std::string decimal_numeric_version_to_string (uint32 version)
 Returns a string representation for a given version. More...
 

Macro Definition Documentation

◆ DBUG_PRINT_BITSET

#define DBUG_PRINT_BITSET (   N,
  FRM,
  BS 
)
Value:
do { \
char buf[256]; \
uint i; \
for (i = 0; i < std::min(uint{sizeof(buf) - 1}, (BS)->n_bits); i++) \
buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
buf[i] = '\0'; \
DBUG_PRINT((N), ((FRM), buf)); \
} while (0)
static char buf[MAX_BUF]
Definition: conf_to_src.cc:73
static bool bitmap_is_set(const MY_BITMAP *map, uint bit)
Definition: my_bitmap.h:95
std::atomic< Type > N
Definition: ut0counter.h:225
Definition: buf0block_hint.cc:30

Function Documentation

◆ decimal_numeric_version_to_string()

std::string decimal_numeric_version_to_string ( uint32  version)

Returns a string representation for a given version.

Parameters
versiona version represented using a integer
Returns
a string for the given version or "unknown" if version is undefined or unknown.

◆ does_source_table_contain_gipk()

bool does_source_table_contain_gipk ( Relay_log_info const *  rli,
TABLE table 
)

Returns if the replicated table contains a GIPK or not.

Note
for servers of older versions that do not fully support GIPK, this method returns a guess based on available information replication has.
Parameters
rliThe relay log object associated to the channel
tableThe table to check for the GIPK
Returns
true if we believe the table has a GIPK, false otherwise.

◆ is_immediate_server_gipk_ready()

bool is_immediate_server_gipk_ready ( THD thd)

Checks if the immediate_server_version supports GIPKs or not.

Parameters
thdThe THD context to check the version
Returns
true if the source server supports GIPK, false otherwise

◆ is_require_row_format_violation()

bool is_require_row_format_violation ( const THD thd)

This method shall evaluate if a command being executed goes against any of the restrictions of server variable session.require_row_format.

Parameters
thdThe thread associated to the command
Returns
true if it violates any restrictions false otherwise

◆ 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)

◆ replace_all_in_str()

std::string replace_all_in_str ( std::string  from,
std::string  find,
std::string  replace 
)

Replaces every occurrence of the string find by the string replace, within the string from and return the resulting string.

The original string from remains untouched.

Parameters
fromthe string to search within.
findthe string to search for.
replacethe string to replace every occurrence of from
Returns
a new string, holding the result of the search and replace operation.