31#ifndef MYSQL_BINLOG_EVENT_EVENT_READER_H
32#define MYSQL_BINLOG_EVENT_EVENT_READER_H
46#define PRINT_READER_STATUS(message) \
47 BAPI_PRINT("debug", (message ": m_buffer= %p, " \
51 m_buffer, m_limit, m_length, Event_reader::position()))
192 const char *
ptr(
unsigned long long length);
247 const char *
forward(
unsigned long long bytes) {
248 BAPI_PRINT(
"debug", (
"Event_reader::forward(%llu)", bytes));
264 set_error(
"Cannot read from out of buffer bounds");
265 BAPI_PRINT(
"debug", (
"Event_reader::memcpy(): "
289 template <
typename T>
290 T
read(
unsigned char bytes =
sizeof(T)) {
293 set_error(
"Cannot read from out of buffer bounds");
295 "sizeof()= %zu, bytes= %u",
302 return (bytes > 1) ?
letoh(value) : value;
315 template <
typename T>
320 set_error(
"Cannot read from out of buffer bounds");
337 template <
typename T>
342 set_error(
"Cannot read from out of buffer bounds");
432 void read_data_map(uint32_t map_len, std::map<std::string, std::string> *
map);
441 void strncpyz(
char *destination,
size_t max_length,
size_t dest_length);
450 void assign(std::vector<uint8_t> *destination,
size_t length);
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
uint64_t le64toh(uint64_t x)
Converting a 64 bit integer from little-endian byte order to host byteorder.
Definition: byte_order_helpers.h:50
Event_reader class purpose is to avoid out-of-buffer reads when deserializing binary log events and i...
Definition: event_reader.h:74
bool has_error()
Returns if the Event_reader is in an error state or not.
Definition: event_reader.h:97
Event_reader(const char *buffer, unsigned long long length)
Event_reader constructor.
Definition: event_reader.h:84
void set_error(const char *error)
Sets Event_reader error state by setting the error message.
Definition: event_reader.cpp:30
uint64_t net_field_length_ll()
Reads a packed value.
Definition: event_reader.cpp:137
uint16_t letoh(uint16_t value)
Wrapper to le16toh to be used by read function.
Definition: event_reader.h:471
unsigned long long position()
Returns the current Event_reader cursor position in bytes.
Definition: event_reader.h:200
const char * get_error()
Returns the pointer to the error message.
Definition: event_reader.h:108
unsigned long long m_length
Definition: event_reader.h:458
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:214
int32_t letoh(int32_t value)
Wrapper to le32toh to be used by read function.
Definition: event_reader.h:480
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:78
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:290
unsigned long long available_to_read()
Returns the amount of bytes still available to read from cursor position.
Definition: event_reader.h:209
unsigned long long length()
Returns the Event_reader buffer length.
Definition: event_reader.h:134
void read_data_set(uint32_t set_len, std::list< const char * > *set)
Reads a transaction context data set.
Definition: event_reader.cpp:160
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:247
uint64_t letoh(uint64_t value)
Wrapper to le64toh to be used by read function.
Definition: event_reader.h:507
void set_length(unsigned long long length)
Sets Event_reader buffer length and limit.
Definition: event_reader.cpp:36
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:338
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:200
uint32_t letoh(uint32_t value)
Wrapper to le32toh to be used by read function.
Definition: event_reader.h:489
const char * m_buffer
Definition: event_reader.h:454
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:173
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:97
T strndup(size_t length)
Returns a pointer to a new string which is a duplicate of the input string.
Definition: event_reader.h:316
unsigned long long m_limit
Definition: event_reader.h:460
void shrink_limit(unsigned long long bytes)
Shrinks the Event_reader buffer limit.
Definition: event_reader.cpp:46
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:223
const char * buffer()
Returns the Event_reader buffer pointer.
Definition: event_reader.h:170
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:178
void read_str_at_most_255_bytes(const char **destination, uint8_t *length)
Reads string from cursor.
Definition: event_reader.cpp:117
int64_t letoh(int64_t value)
Wrapper to le64toh to be used by read function.
Definition: event_reader.h:498
T memcpy()
Copies a basic type - bool, char, int, long, double, etc - from the buffer, moves the cursor forward ...
Definition: event_reader.h:261
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:67
const char * m_ptr
Definition: event_reader.h:456
const char * m_error
Definition: event_reader.h:462
#define PRINT_READER_STATUS(message)
Definition: event_reader.h:46
static int flags[50]
Definition: hp_test1.cc:40
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:62
uint32_t le32toh(uint32_t x)
Converting a 32 bit integer from little-endian byte order to host byteorder.
Definition: byteorder.h:78
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1105
The namespace contains classes representing events that can occur in a replication stream.
Definition: binlog_event.cpp:38
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:150
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2884
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2894
Contains wrapper functions for memory allocation and deallocation.
#define BAPI_ASSERT(x)
Definition: wrapper_functions.h:61
#define BAPI_PRINT(name, params)
Definition: wrapper_functions.h:62