From af415f58c3657e8bdea751bf2dfc364edfc38c40 Mon Sep 17 00:00:00 2001 From: Mark Riddoch Date: Wed, 7 Jan 2015 17:38:41 +0000 Subject: [PATCH] Add support for select @@max_allowed_packet --- server/modules/include/blr.h | 10 ++++++---- server/modules/routing/binlog/blr_master.c | 7 +++++++ server/modules/routing/binlog/blr_slave.c | 8 +++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/server/modules/include/blr.h b/server/modules/include/blr.h index f7b8f38ea..565bc35cf 100644 --- a/server/modules/include/blr.h +++ b/server/modules/include/blr.h @@ -230,6 +230,7 @@ typedef struct { GWBUF *selectver; /*< select version() */ GWBUF *selectvercom; /*< select @@version_comment */ GWBUF *selecthostname;/*< select @@hostname */ + GWBUF *map; /*< select @@max_allowed_packet */ uint8_t *fde_event; /*< Format Description Event */ int fde_len; /*< Length of fde_event */ } MASTER_RESPONSES; @@ -305,17 +306,18 @@ typedef struct router_instance { #define BLRM_SELECTVER 0x000E #define BLRM_SELECTVERCOM 0x000F #define BLRM_SELECTHOSTNAME 0x0010 -#define BLRM_REGISTER 0x0011 -#define BLRM_BINLOGDUMP 0x0012 +#define BLRM_MAP 0x0011 +#define BLRM_REGISTER 0x0012 +#define BLRM_BINLOGDUMP 0x0013 -#define BLRM_MAXSTATE 0x0012 +#define BLRM_MAXSTATE 0x0013 static char *blrm_states[] = { "Unconnected", "Connecting", "Authenticated", "Timestamp retrieval", "Server ID retrieval", "HeartBeat Period setup", "binlog checksum config", "binlog checksum rerieval", "GTID Mode retrieval", "Master UUID retrieval", "Set Slave UUID", "Set Names latin1", "Set Names utf8", "select 1", "select version()", "select @@version_comment", "select @@hostname", - "Register slave", "Binlog Dump" }; + "select @@mx_allowed_packet", "Register slave", "Binlog Dump" }; #define BLRS_CREATED 0x0000 #define BLRS_UNREGISTERED 0x0001 diff --git a/server/modules/routing/binlog/blr_master.c b/server/modules/routing/binlog/blr_master.c index 76129ff92..c05a77eae 100644 --- a/server/modules/routing/binlog/blr_master.c +++ b/server/modules/routing/binlog/blr_master.c @@ -452,6 +452,13 @@ char query[128]; case BLRM_SELECTHOSTNAME: // Response to SELECT @@hostname should be stored router->saved_master.selecthostname = buf; + buf = blr_make_query("SELECT @@max_allowed_packet;"); + router->master_state = BLRM_MAP; + router->master->func.write(router->master, buf); + break; + case BLRM_MAP: + // Response to SELECT @@max_allowed_packet should be stored + router->saved_master.map = buf; buf = blr_make_registration(router); router->master_state = BLRM_REGISTER; router->master->func.write(router->master, buf); diff --git a/server/modules/routing/binlog/blr_slave.c b/server/modules/routing/binlog/blr_slave.c index a98de60f7..31160032f 100644 --- a/server/modules/routing/binlog/blr_slave.c +++ b/server/modules/routing/binlog/blr_slave.c @@ -141,7 +141,7 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue) * when MaxScale registered as a slave. The exception to the rule is the * request to obtain the current timestamp value of the server. * - * Seven select statements are currently supported: + * Eight select statements are currently supported: * SELECT UNIX_TIMESTAMP(); * SELECT @master_binlog_checksum * SELECT @@GLOBAL.GTID_MODE @@ -149,6 +149,7 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue) * SELECT 1 * SELECT @@version_comment limit 1 * SELECT @@hostname + * SELECT @@max_allowed_packet * * Two show commands are supported: * SHOW VARIABLES LIKE 'SERVER_ID' @@ -228,6 +229,11 @@ int query_len; free(query_text); return blr_slave_replay(router, slave, router->saved_master.selecthostname); } + else if (strcasecmp(word, "@@max_allowed_packet") == 0) + { + free(query_text); + return blr_slave_replay(router, slave, router->saved_master.map); + } } else if (strcasecmp(word, "SHOW") == 0) {