Clean up common binlogrouter headers
Cleaned up blr_constants.h and moved the REP_HEADER construction helper into binlog_common.h.
This commit is contained in:
parent
8721c9117a
commit
ac6370afcf
@ -42,6 +42,20 @@ bool binlog_next_file_exists(const char* binlogdir, const char* binlog);
|
||||
uint32_t extract_field(uint8_t *src, int bits);
|
||||
const char* binlog_event_name(int type);
|
||||
|
||||
static inline REP_HEADER construct_header(uint8_t* ptr)
|
||||
{
|
||||
REP_HEADER hdr;
|
||||
|
||||
hdr.timestamp = extract_field(ptr, 32);
|
||||
hdr.event_type = ptr[4];
|
||||
hdr.serverid = extract_field(&ptr[5], 32);
|
||||
hdr.event_size = extract_field(&ptr[9], 32);
|
||||
hdr.next_pos = extract_field(&ptr[13], 32);
|
||||
hdr.flags = extract_field(&ptr[17], 16);
|
||||
|
||||
return hdr;
|
||||
}
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
#endif /* BINLOG_COMMON_H */
|
||||
|
@ -175,36 +175,6 @@ MXS_BEGIN_DECLS
|
||||
#define MARIADB_FL_DDL 32
|
||||
#define MARIADB_FL_STANDALONE 1
|
||||
|
||||
/**
|
||||
* Some useful macros for examining the MySQL Response packets
|
||||
*/
|
||||
#define MYSQL_RESPONSE_OK(buf) (*((uint8_t *)GWBUF_DATA(buf) + 4) == 0x00)
|
||||
#define MYSQL_RESPONSE_EOF(buf) (*((uint8_t *)GWBUF_DATA(buf) + 4) == 0xfe)
|
||||
#define MYSQL_RESPONSE_ERR(buf) (*((uint8_t *)GWBUF_DATA(buf) + 4) == 0xff)
|
||||
#define MYSQL_ERROR_CODE(buf) ((uint8_t *)GWBUF_DATA(buf) + 5)
|
||||
#define MYSQL_ERROR_MSG(buf) ((uint8_t *)GWBUF_DATA(buf) + 7)
|
||||
#define MYSQL_COMMAND(buf) (*((uint8_t *)GWBUF_DATA(buf) + 4))
|
||||
|
||||
/**
|
||||
* Macros to extract common fields
|
||||
*/
|
||||
#define INLINE_EXTRACT 1 /* Set to 0 for debug purposes */
|
||||
|
||||
#if INLINE_EXTRACT
|
||||
#define EXTRACT16(x) (*(uint8_t *)(x) | (*((uint8_t *)(x) + 1) << 8))
|
||||
#define EXTRACT24(x) (*(uint8_t *)(x) | \
|
||||
(*((uint8_t *)(x) + 1) << 8) | \
|
||||
(*((uint8_t *)(x) + 2) << 16))
|
||||
#define EXTRACT32(x) (*(uint8_t *)(x) | \
|
||||
(*((uint8_t *)(x) + 1) << 8) | \
|
||||
(*((uint8_t *)(x) + 2) << 16) | \
|
||||
(*((uint8_t *)(x) + 3) << 24))
|
||||
#else
|
||||
#define EXTRACT16(x) extract_field((x), 16)
|
||||
#define EXTRACT24(x) extract_field((x), 24)
|
||||
#define EXTRACT32(x) extract_field((x), 32)
|
||||
#endif
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -389,19 +389,7 @@ void Rpl::add_create(STableCreateEvent create)
|
||||
}
|
||||
}
|
||||
|
||||
REP_HEADER construct_header(uint8_t* ptr)
|
||||
{
|
||||
REP_HEADER hdr;
|
||||
|
||||
hdr.timestamp = EXTRACT32(ptr);
|
||||
hdr.event_type = ptr[4];
|
||||
hdr.serverid = EXTRACT32(&ptr[5]);
|
||||
hdr.event_size = extract_field(&ptr[9], 32);
|
||||
hdr.next_pos = EXTRACT32(&ptr[13]);
|
||||
hdr.flags = EXTRACT16(&ptr[17]);
|
||||
|
||||
return hdr;
|
||||
}
|
||||
|
||||
bool read_header(Avro* router, unsigned long long pos, REP_HEADER* hdr, avro_binlog_end_t* rc)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user