MySQL  8.0.18
Source Code Documentation
rpl_utility.h File Reference
#include <sys/types.h>
#include <unordered_map>
#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_LIST
 Extend the normal table list 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 *metadata_ptr, enum_field_types 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...
 

Macro Definition Documentation

◆ DBUG_PRINT_BITSET

#define DBUG_PRINT_BITSET (   N,
  FRM,
  BS 
)
Value:
do { \
char buf[256]; \
uint i; \
for (i = 0; i < MY_MIN(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 bool bitmap_is_set(const MY_BITMAP *map, uint bit)
Definition: my_bitmap.h:103
std::atomic< Type > N
Definition: ut0counter.h:230
#define MY_MIN(a, b)
Definition: my_macros.h:62

Function Documentation

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