-
Notifications
You must be signed in to change notification settings - Fork 260
rpl_data_structures
Structures and type definitions for Binglog/Replication API are defined in source file include/mariadb_rpl.h
.
MARIADB_STRING
is a simple structure (same as MYSQL_STRING
and MYSQL_LEX_STRING
) which stores a string together with its length.
typedef struct {
char *str;
size_t length;
} MARIADB_STRING;
MARIADB_GTID
is used to store the global transaction id. The global transaction id is defined by three numbers:
The domain id, the server id and the sequence number.
typedef struct st_mariadb_gtid {
unsigned int domain_id;
unsigned int server_id;
unsigned long long sequence_nr;
} MARIADB_GTID;
MARIADB_RPL
is the generic replication handle, which represents a replication connection and is used by all binlog/replication API calls. The MARIADB_RPL
structure is considered to be opaque, instead of accessing its internal members you should use the api functions mariadb_rpl_optionsv
and mariadb_rpl_get_optionsv
.
typedef struct st_mariadb_rpl {
unsigned int version;
MYSQL *mysql;
char *filename;
uint32_t filename_length;
unsigned char *buffer;
unsigned long buffer_size;
uint32_t server_id;
unsigned long start_position;
uint32_t flags;
uint8_t fd_header_len; /* header len from last format description event */
} MARIADB_RPL;
MARIADB_RPL_EVENT
structure is returned by mariadb_rpl_fetch()
API function. Beside a common header it contains different event types which are combined in event
union.
typedef struct st_mariadb_rpl_event
{
/* common header */
MA_MEM_ROOT memroot;
unsigned int checksum;
char ok;
enum mariadb_rpl_event event_type;
unsigned int timestamp;
unsigned int server_id;
unsigned int event_length;
unsigned int next_event_pos;
unsigned short flags;
/****************/
union {
struct st_mariadb_rpl_rotate_event rotate;
struct st_mariadb_rpl_query_event query;
struct st_mariadb_rpl_format_description_event format_description;
struct st_mariadb_rpl_gtid_list_event gtid_list;
struct st_mariadb_rpl_checkpoint_event checkpoint;
struct st_mariadb_rpl_xid_event xid;
struct st_mariadb_rpl_gtid_event gtid;
struct st_mariadb_rpl_annotate_rows_event annotate_rows;
struct st_mariadb_rpl_table_map_event table_map;
struct st_mariadb_rpl_rand_event rand;
struct st_mariadb_rpl_encryption_event encryption;
struct st_mariadb_rpl_intvar_event intvar;
struct st_mariadb_rpl_uservar_event uservar;
struct st_mariadb_rpl_rows_event rows;
struct st_mariadb_rpl_heartbeat_event heartbeat;
} event;
} MARIADB_RPL_EVENT;
Depending on the event type information sent by master will be stored in the corresponding member of the event union:
event_type value= 160 (0xA0)
struct st_mariadb_rpl_annotate_rows_event {
MARIADB_STRING statement;
};
event_type value= 161 (0xA1)
struct st_mariadb_rpl_checkpoint_event {
MARIADB_STRING filename;
};
event_type value= 164 (0xA4)
struct st_mariadb_rpl_encryption_event {
char scheme;
unsigned int key_version;
char *nonce;
};
event_type value= 15 (0x0F)
struct st_mariadb_rpl_format_description_event
{
uint16_t format;
char *server_version;
uint32_t timestamp;
uint8_t header_len;
};
event_type value= 162 (0xA2)
struct st_mariadb_rpl_gtid_event {
uint64_t sequence_nr;
uint32_t domain_id;
uint8_t flags;
uint64_t commit_id;
};
event_type value= 163 (0xA3)
struct st_mariadb_rpl_gtid_list_event {
uint32_t gtid_cnt;
MARIADB_GTID *gtid;
};
event_type value= 27 (0x1B)
struct st_mariadb_rpl_heartbeat_event {
uint32_t timestamp;
uint32_t next_position;
uint8_t type;
uint16_t flags;
};
event_type value=5 (0x05)
struct st_mariadb_rpl_intvar_event {
char type;
unsigned long long value;
};
event_type value=2 (0x02)
struct st_mariadb_rpl_query_event {
uint32_t thread_id;
uint32_t seconds;
MARIADB_STRING database;
uint32_t errornr;
MARIADB_STRING status;
MARIADB_STRING statement;
};
event_type value=13 (0x0D)
struct st_mariadb_rpl_rand_event {
unsigned long long first_seed;
unsigned long long second_seed;
};
event_type value=4 (0x04)
struct st_mariadb_rpl_rotate_event {
unsigned long long position;
MARIADB_STRING filename;
};
MariaDB Connector/C Reference