MXS-1249: Add utility function for setting the server version

Add utility function for setting the server version from a
MySQL handle.
This commit is contained in:
Johan Wikman
2017-06-16 13:46:34 +03:00
parent 0d784da0ee
commit d927f1d3c6
2 changed files with 30 additions and 0 deletions

View File

@ -83,4 +83,14 @@ mxs_mysql_name_kind_t mxs_mysql_name_to_pcre(char *pcre,
const char *mysql, const char *mysql,
mxs_pcre_quote_approach_t approach); 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 MXS_END_DECLS

View File

@ -285,3 +285,23 @@ mxs_mysql_name_kind_t mxs_mysql_name_to_pcre(char *pcre,
return rv; 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;
}