diff --git a/server/modules/routing/binlogrouter/blr.h b/server/modules/routing/binlogrouter/blr.h index b7668d1e2..466d5f93f 100644 --- a/server/modules/routing/binlogrouter/blr.h +++ b/server/modules/routing/binlogrouter/blr.h @@ -229,6 +229,9 @@ typedef enum #define BLR_MASTER_CONNECT_RETRY "60" #define BLR_MASTER_RETRY_COUNT "1000" +/* Default value for @@max_connections SQL var */ +#define BLR_DEFAULT_MAX_CONNS 151 + /* max size for error message returned to client */ #define BINLOG_ERROR_MSG_LEN 700 diff --git a/server/modules/routing/binlogrouter/blr_slave.c b/server/modules/routing/binlogrouter/blr_slave.c index fd20caedd..be6d42a4b 100644 --- a/server/modules/routing/binlogrouter/blr_slave.c +++ b/server/modules/routing/binlogrouter/blr_slave.c @@ -6393,12 +6393,17 @@ static bool blr_handle_simple_select_stmt(ROUTER_INSTANCE *router, BLR_TYPE_INT); return true; } + /* Handle MariaDB 10 GTID vars */ else if ((strcasecmp(word, "@@gtid_current_pos") == 0) || - (strcasecmp(word, "@@global.gtid_current_pos") == 0)) + (strcasecmp(word, "@@global.gtid_current_pos") == 0) || + (strcasecmp(word, "@@gtid_binlog_pos") == 0) || + (strcasecmp(word, "@@global.gtid_binlog_pos") == 0) || + (strcasecmp(word, "@@gtid_slave_pos") == 0) || + (strcasecmp(word, "@@global.gtid_slave_pos") == 0)) { char heading[40]; char mariadb_gtid[GTID_MAX_LEN + 1]; - mariadb_gtid[0] = '\0'; + mariadb_gtid[0] = 0; strcpy(heading, word); if (router->mariadb10_compat && @@ -6409,6 +6414,13 @@ static bool blr_handle_simple_select_stmt(ROUTER_INSTANCE *router, spinlock_release(&router->binlog_lock); } + /* Return empty gtid_slave_pos if master GTID registration is off */ + if (!router->mariadb10_master_gtid && + strcasestr(word, "gtid_slave_pos" ) != NULL) + { + mariadb_gtid[0] = 0; + } + blr_slave_send_var_value(router, slave, heading, @@ -6437,6 +6449,50 @@ static bool blr_handle_simple_select_stmt(ROUTER_INSTANCE *router, return true; } } + else if ((strcasecmp(word, "@@global.max_connections") == 0) || + (strcasecmp(word, "@@max_connections") == 0)) + { + char max_conns[40]; + /* to ensure we match the case in query and response */ + char heading[40]; + + sprintf(max_conns, "%d", !router->service->max_connections ? + BLR_DEFAULT_MAX_CONNS : + router->service->max_connections); + strcpy(heading, word); + + blr_slave_send_var_value(router, + slave, + heading, + max_conns, + BLR_TYPE_INT); + } + else if ((strcasecmp(word, "@@global.read_only") == 0) || + (strcasecmp(word, "@@read_only") == 0)) + { + /* to ensure we match the case in query and response */ + char heading[40]; + strcpy(heading, word); + + blr_slave_send_var_value(router, + slave, + heading, + "0", + BLR_TYPE_INT); + } + else if ((strcasecmp(word, "@@global.log_bin") == 0) || + (strcasecmp(word, "@@log_bin") == 0)) + { + /* to ensure we match the case in query and response */ + char heading[40]; + strcpy(heading, word); + + blr_slave_send_var_value(router, + slave, + heading, + "1", + BLR_TYPE_INT); + } return false; } @@ -7463,7 +7519,7 @@ static bool blr_handle_set_stmt(ROUTER_INSTANCE *router, return true; } } - else if (strstr(word, "@slave_connect_state") != NULL) + else if (strcasestr(word, "@slave_connect_state") != NULL) { /* If not mariadb an error message will be returned */ if (slave->mariadb10_compat &&