30#ifndef MYSQL_BINLOG_EVENT_EVENT_READER_H
31#define MYSQL_BINLOG_EVENT_EVENT_READER_H
45#define PRINT_READER_STATUS(message) \
46 BAPI_PRINT("debug", (message ": m_buffer= %p, " \
50 m_buffer, m_limit, m_length, Event_reader::position()))
191 const char *
ptr(
unsigned long long length);
246 const char *
forward(
unsigned long long bytes) {
247 BAPI_PRINT(
"debug", (
"Event_reader::forward(%llu)", bytes));
263 set_error(
"Cannot read from out of buffer bounds");
264 BAPI_PRINT(
"debug", (
"Event_reader::memcpy(): "
288 template <
typename T>
289 T
read(
unsigned char bytes =
sizeof(T)) {
292 set_error(
"Cannot read from out of buffer bounds");
294 "sizeof()= %zu, bytes= %u",
301 return (bytes > 1) ?
letoh(value) : value;
314 template <
typename T>
319 set_error(
"Cannot read from out of buffer bounds");
336 template <
typename T>
341 set_error(
"Cannot read from out of buffer bounds");
431 void read_data_map(uint32_t map_len, std::map<std::string, std::string> *
map);
440 void strncpyz(
char *destination,
size_t max_length,
size_t dest_length);
449 void assign(std::vector<uint8_t> *destination,
size_t length);
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:250
Event_reader class purpose is to avoid out-of-buffer reads when deserializing binary log events and i...
Definition: event_reader.h:73
bool has_error()
Returns if the Event_reader is in an error state or not.
Definition: event_reader.h:96
Event_reader(const char *buffer, unsigned long long length)
Event_reader constructor.
Definition: event_reader.h:83
void set_error(const char *error)
Sets Event_reader error state by setting the error message.
Definition: event_reader.cpp:29
uint64_t net_field_length_ll()
Reads a packed value.
Definition: event_reader.cpp:136
uint16_t letoh(uint16_t value)
Wrapper to le16toh to be used by read function.
Definition: event_reader.h:470
unsigned long long position()
Returns the current Event_reader cursor position in bytes.
Definition: event_reader.h:199
const char * get_error()
Returns the pointer to the error message.
Definition: event_reader.h:107
unsigned long long m_length
Definition: event_reader.h:457
void assign(std::vector< uint8_t > *destination, size_t length)
Fills a vector with a sequence of bytes from the cursor.
Definition: event_reader.cpp:213
int32_t letoh(int32_t value)
Wrapper to le32toh to be used by read function.
Definition: event_reader.h:479
void alloc_and_memcpy(unsigned char **destination, size_t length, int flags)
Allocates memory to a destination buffer, copies from the cursor to the destination buffer using memc...
Definition: event_reader.cpp:77
T read(unsigned char bytes=sizeof(T))
Copies a basic arithmetic type - uint8_t, [u]int16_t, [u]int32_t, [u]int64_t - from the buffer,...
Definition: event_reader.h:289
unsigned long long available_to_read()
Returns the amount of bytes still available to read from cursor position.
Definition: event_reader.h:208
unsigned long long length()
Returns the Event_reader buffer length.
Definition: event_reader.h:133
void read_data_set(uint32_t set_len, std::list< const char * > *set)
Reads a transaction context data set.
Definition: event_reader.cpp:159
const char * forward(unsigned long long bytes)
Moves the buffer position forward to a given relative position and returns the pointer to the buffer ...
Definition: event_reader.h:246
uint64_t letoh(uint64_t value)
Wrapper to le64toh to be used by read function.
Definition: event_reader.h:506
void set_length(unsigned long long length)
Sets Event_reader buffer length and limit.
Definition: event_reader.cpp:35
void memcpy(T destination, size_t length)
Copies from the cursor to an already existent (and allocated) buffer and moves forward the cursor.
Definition: event_reader.h:337
void strncpyz(char *destination, size_t max_length, size_t dest_length)
Copy a string into the destination buffer up to a max length.
Definition: event_reader.cpp:199
uint32_t letoh(uint32_t value)
Wrapper to le32toh to be used by read function.
Definition: event_reader.h:488
const char * m_buffer
Definition: event_reader.h:453
void read_data_map(uint32_t map_len, std::map< std::string, std::string > *map)
Reads a view change certification map.
Definition: event_reader.cpp:172
void alloc_and_strncpy(char **destination, size_t length, int flags)
Allocates memory to a destination buffer, copies from the cursor to the destination buffer using strn...
Definition: event_reader.cpp:96
T strndup(size_t length)
Returns a pointer to a new string which is a duplicate of the input string.
Definition: event_reader.h:315
unsigned long long m_limit
Definition: event_reader.h:459
void shrink_limit(unsigned long long bytes)
Shrinks the Event_reader buffer limit.
Definition: event_reader.cpp:45
bool can_read(unsigned long long bytes)
Returns if the Event_reader can read a given amount of bytes from cursor position.
Definition: event_reader.h:222
const char * buffer()
Returns the Event_reader buffer pointer.
Definition: event_reader.h:169
const char * ptr()
Returns a pointer to the Event_reader cursor (next position to be read by the Event_reader functions)...
Definition: event_reader.h:177
void read_str_at_most_255_bytes(const char **destination, uint8_t *length)
Reads string from cursor.
Definition: event_reader.cpp:116
int64_t letoh(int64_t value)
Wrapper to le64toh to be used by read function.
Definition: event_reader.h:497
T memcpy()
Copies a basic type - bool, char, int, long, double, etc - from the buffer, moves the cursor forward ...
Definition: event_reader.h:260
const char * go_to(unsigned long long position)
Moves cursor to a given absolute buffer position and returns the pointer to the cursor.
Definition: event_reader.cpp:66
const char * m_ptr
Definition: event_reader.h:455
const char * m_error
Definition: event_reader.h:461
#define PRINT_READER_STATUS(message)
Definition: event_reader.h:45
static int flags[50]
Definition: hp_test1.cc:39
The file contains functions to convert the byte encoding of integer values to and from little-endian ...
uint16_t le16toh(uint16_t x)
Converting a 16 bit integer from little-endian byte order to host byteorder.
Definition: byteorder.h:60
uint32_t le32toh(uint32_t x)
Converting a 32 bit integer from little-endian byte order to host byteorder.
Definition: byteorder.h:76
uint64_t le64toh(uint64_t x)
Converting a 64 bit integer from little-endian byte order to host byteorder.
Definition: byteorder.h:110
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1085
The namespace contains classes representing events that can occur in a replication stream.
Definition: binlog_event.cpp:35
const char * bapi_strndup(const char *destination, size_t n)
This is a wrapper function, and returns a pointer to a new string which is a duplicate of the input s...
Definition: wrapper_functions.h:149
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2881
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2891
Contains wrapper functions for memory allocation and deallocation.
#define BAPI_ASSERT(x)
Definition: wrapper_functions.h:60
#define BAPI_PRINT(name, params)
Definition: wrapper_functions.h:61