Merge branch 'develop' into MXS-544
This commit is contained in:
@ -44,10 +44,12 @@
|
||||
#include <stdint.h>
|
||||
#include <memlog.h>
|
||||
#include <zlib.h>
|
||||
#include <mysql_client_server_protocol.h>
|
||||
|
||||
#define BINLOG_FNAMELEN 255
|
||||
#define BLR_PROTOCOL "MySQLBackend"
|
||||
#define BINLOG_MAGIC { 0xfe, 0x62, 0x69, 0x6e }
|
||||
#define BINLOG_MAGIC_SIZE 4
|
||||
#define BINLOG_NAMEFMT "%s.%06d"
|
||||
#define BINLOG_NAME_ROOT "mysql-bin"
|
||||
|
||||
@ -197,6 +199,17 @@
|
||||
#define MYSQL_ERROR_MSG(buf) ((uint8_t *)GWBUF_DATA(buf) + 7)
|
||||
#define MYSQL_COMMAND(buf) (*((uint8_t *)GWBUF_DATA(buf) + 4))
|
||||
|
||||
/** Possible states of an event sent by the master */
|
||||
enum blr_event_state
|
||||
{
|
||||
BLR_EVENT_DONE, /*< No event being processed */
|
||||
BLR_EVENT_STARTED, /*< The first packet of an event which spans multiple packets
|
||||
* has been received */
|
||||
BLR_EVENT_ONGOING, /*< Other packets of a multi-packet event are being processed */
|
||||
BLR_EVENT_COMPLETE /*< A multi-packet event has been successfully processed
|
||||
* but the router is not yet ready to process another one */
|
||||
};
|
||||
|
||||
/* Master Server configuration struct */
|
||||
typedef struct master_server_config {
|
||||
char *host;
|
||||
@ -414,6 +427,13 @@ typedef struct router_instance {
|
||||
SPINLOCK binlog_lock; /*< Lock to control update of the binlog position */
|
||||
int trx_safe; /*< Detect and handle partial transactions */
|
||||
int pending_transaction; /*< Pending transaction */
|
||||
enum blr_event_state master_event_state; /*< Packet read state */
|
||||
uint32_t stored_checksum; /*< The current value of the checksum */
|
||||
uint8_t partial_checksum[MYSQL_CHECKSUM_LEN]; /*< The partial value of the checksum
|
||||
* received from the master */
|
||||
uint8_t partial_checksum_bytes; /*< How many bytes of the checksum we have read */
|
||||
uint64_t checksum_size; /*< Data size for the checksum */
|
||||
REP_HEADER stored_header; /*< Relication header of the event the master is sending */
|
||||
uint64_t last_safe_pos; /* last committed transaction */
|
||||
char binlog_name[BINLOG_FNAMELEN+1];
|
||||
/*< Name of the current binlog file */
|
||||
@ -424,7 +444,8 @@ typedef struct router_instance {
|
||||
int binlog_fd; /*< File descriptor of the binlog
|
||||
* file being written
|
||||
*/
|
||||
uint64_t last_written; /*< Position of last event written */
|
||||
uint64_t last_written; /*< Position of the last write operation */
|
||||
uint64_t last_event_pos; /*< Position of last event written */
|
||||
uint64_t current_safe_event;
|
||||
/*< Position of the latest safe event being sent to slaves */
|
||||
char prevbinlog[BINLOG_FNAMELEN+1];
|
||||
@ -555,7 +576,7 @@ extern int blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool
|
||||
extern void blr_init_cache(ROUTER_INSTANCE *);
|
||||
|
||||
extern int blr_file_init(ROUTER_INSTANCE *);
|
||||
extern int blr_write_binlog_record(ROUTER_INSTANCE *, REP_HEADER *,uint8_t *);
|
||||
extern int blr_write_binlog_record(ROUTER_INSTANCE *, REP_HEADER *, uint32_t pos, uint8_t *);
|
||||
extern int blr_file_rotate(ROUTER_INSTANCE *, char *, uint64_t);
|
||||
extern void blr_file_flush(ROUTER_INSTANCE *);
|
||||
extern BLFILE *blr_open_binlog(ROUTER_INSTANCE *, char *);
|
||||
|
@ -65,12 +65,14 @@
|
||||
#include <dbusers.h>
|
||||
#include <version.h>
|
||||
#include <housekeeper.h>
|
||||
#include <mysql.h>
|
||||
|
||||
#define GW_MYSQL_VERSION "MaxScale " MAXSCALE_VERSION
|
||||
#define GW_MYSQL_VERSION "5.5.5-"MAXSCALE_VERSION"-maxscale"
|
||||
#define GW_MYSQL_LOOP_TIMEOUT 300000000
|
||||
#define GW_MYSQL_READ 0
|
||||
#define GW_MYSQL_WRITE 1
|
||||
#define MYSQL_HEADER_LEN 4L
|
||||
#define MYSQL_CHECKSUM_LEN 4L
|
||||
|
||||
#define GW_MYSQL_PROTOCOL_VERSION 10 // version is 10
|
||||
#define GW_MYSQL_HANDSHAKE_FILLER 0x00
|
||||
@ -81,6 +83,9 @@
|
||||
#define GW_MYSQL_SCRAMBLE_SIZE 20
|
||||
#define GW_SCRAMBLE_LENGTH_323 8
|
||||
|
||||
/** Maximum length of a MySQL packet */
|
||||
#define MYSQL_PACKET_LENGTH_MAX 0x00ffffff
|
||||
|
||||
#ifndef MYSQL_SCRAMBLE_LEN
|
||||
# define MYSQL_SCRAMBLE_LEN GW_MYSQL_SCRAMBLE_SIZE
|
||||
#endif
|
||||
@ -236,9 +241,15 @@ typedef enum
|
||||
),
|
||||
} gw_mysql_capabilities_t;
|
||||
|
||||
// mysql.h from Connector-C exposes this enum, while mysql.h from
|
||||
// MariaDB does not.
|
||||
// TODO: This should probably be removed as Connector-C will be
|
||||
// TODO: a pre-requisite for building MaxScale.
|
||||
#if defined(LIBMARIADB)
|
||||
typedef enum enum_server_command mysql_server_cmd_t;
|
||||
#else
|
||||
/** Copy from enum in mariadb-5.5 mysql_com.h */
|
||||
typedef enum mysql_server_cmd {
|
||||
MYSQL_COM_UNDEFINED = -1,
|
||||
MYSQL_COM_SLEEP = 0,
|
||||
MYSQL_COM_QUIT,
|
||||
MYSQL_COM_INIT_DB,
|
||||
@ -271,7 +282,9 @@ typedef enum mysql_server_cmd {
|
||||
MYSQL_COM_DAEMON,
|
||||
MYSQL_COM_END /*< Must be the last */
|
||||
} mysql_server_cmd_t;
|
||||
#endif
|
||||
|
||||
static const mysql_server_cmd_t MYSQL_COM_UNDEFINED = (mysql_server_cmd_t)-1;
|
||||
|
||||
/**
|
||||
* List of server commands, and number of response packets are stored here.
|
||||
@ -335,7 +348,6 @@ typedef struct {
|
||||
|
||||
MySQLProtocol* mysql_protocol_init(DCB* dcb, int fd);
|
||||
void mysql_protocol_done (DCB* dcb);
|
||||
MySQLProtocol *gw_mysql_init(MySQLProtocol *data);
|
||||
int gw_receive_backend_auth(MySQLProtocol *protocol);
|
||||
int gw_decode_mysql_server_handshake(MySQLProtocol *protocol, uint8_t *payload);
|
||||
int gw_read_backend_handshake(MySQLProtocol *protocol);
|
||||
|
Reference in New Issue
Block a user