diff --git a/include/maxscale/mysql_utils.h b/include/maxscale/mysql_utils.h index 4eac68fba..222607c16 100644 --- a/include/maxscale/mysql_utils.h +++ b/include/maxscale/mysql_utils.h @@ -83,4 +83,14 @@ mxs_mysql_name_kind_t mxs_mysql_name_to_pcre(char *pcre, const char *mysql, mxs_pcre_quote_approach_t approach); +/** + * Set the server information + * + * @param mysql A MySQL handle to the server. + * @param server The server whose version information should be updated. + * + * @return True, if the information could be set, false if an error occurred. + */ +bool mxs_mysql_set_server_version(MYSQL* mysql, SERVER* server); + MXS_END_DECLS diff --git a/server/core/mysql_utils.cc b/server/core/mysql_utils.cc index 94f87bc3e..8fa7a6438 100644 --- a/server/core/mysql_utils.cc +++ b/server/core/mysql_utils.cc @@ -285,3 +285,23 @@ mxs_mysql_name_kind_t mxs_mysql_name_to_pcre(char *pcre, return rv; } + +bool mxs_mysql_set_server_version(MYSQL* mysql, SERVER* server) +{ + bool rv = false; + + const char* s = mysql_get_server_info(mysql); + + if (s) + { + unsigned long v = mysql_get_server_version(mysql); + + unsigned long major = v / 10000; + unsigned long minor = (v - major * 10000) / 100; + unsigned long patch = v - major * 10000 - minor * 100; + + rv = server_set_version(server, s, major, minor, patch); + } + + return rv; +}