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:
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user