From 8f1d807f1b51ef943eefcdba33503f3b88514e3d Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Fri, 24 Aug 2018 12:54:16 +0300 Subject: [PATCH] MXS-2011 Remove "CHANGE MASTER" when testing The blr_handle_change_master() will receive the string without "CHANGE MASTER" when running BLR. --- .../modules/routing/binlogrouter/blr_slave.cc | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/server/modules/routing/binlogrouter/blr_slave.cc b/server/modules/routing/binlogrouter/blr_slave.cc index 2158b375c..a9d7a365f 100644 --- a/server/modules/routing/binlogrouter/blr_slave.cc +++ b/server/modules/routing/binlogrouter/blr_slave.cc @@ -5365,6 +5365,29 @@ blr_slave_send_columndef_with_info_schema(ROUTER_INSTANCE *router, return MXS_SESSION_ROUTE_REPLY(slave->dcb->session, pkt); } +static char* bypass_change_master(char* input) +{ + // Very simple, basically ASSUMES there is a "CHANGE MASTER" at the beginning. + + static const char CHANGE[] = "change"; + + char* p = strcasestr(input, CHANGE); + if (p) + { + input = p + sizeof(CHANGE) - 1; + + static const char MASTER[] = "master"; + + p = strcasestr(input, MASTER); + if (p) + { + input = p + sizeof(MASTER) - 1; + } + } + + return input; +} + /** * Interface for testing blr_parse_change_master_command() * @@ -5379,7 +5402,7 @@ blr_test_parse_change_master_command(char *input, char *error_string, ChangeMasterOptions *config) { - return blr_parse_change_master_command(input, + return blr_parse_change_master_command(bypass_change_master(input), error_string, config); } @@ -5416,7 +5439,7 @@ blr_test_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error) { - return blr_handle_change_master(router, command, error); + return blr_handle_change_master(router, bypass_change_master(command), error); }