MXS-1249: Prepare for storing version in server structure
The behaviour of the query classifier needs to be different depending on the actual version of the server. There is already a human readable string, but for programmatic use it needs to be in a format that can easily be parsed.
This commit is contained in:
@ -63,6 +63,16 @@ typedef struct
|
|||||||
int n_persistent; /**< Current persistent pool */
|
int n_persistent; /**< Current persistent pool */
|
||||||
} SERVER_STATS;
|
} SERVER_STATS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The server version.
|
||||||
|
*/
|
||||||
|
typedef struct server_version
|
||||||
|
{
|
||||||
|
uint32_t major;
|
||||||
|
uint32_t minor;
|
||||||
|
uint32_t patch;
|
||||||
|
} SERVER_VERSION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SERVER structure defines a backend server. Each server has a name
|
* The SERVER structure defines a backend server. Each server has a name
|
||||||
* or IP address for the server, a port that the server listens on and
|
* or IP address for the server, a port that the server listens on and
|
||||||
@ -91,6 +101,7 @@ typedef struct server
|
|||||||
struct server *next; /**< Next server */
|
struct server *next; /**< Next server */
|
||||||
struct server *nextdb; /**< Next server in list attached to a service */
|
struct server *nextdb; /**< Next server in list attached to a service */
|
||||||
char version_string[MAX_SERVER_VERSION_LEN]; /**< Server version string, i.e. MySQL server version */
|
char version_string[MAX_SERVER_VERSION_LEN]; /**< Server version string, i.e. MySQL server version */
|
||||||
|
SERVER_VERSION version; /**< Server version information */
|
||||||
long node_id; /**< Node id, server_id for M/S or local_index for Galera */
|
long node_id; /**< Node id, server_id for M/S or local_index for Galera */
|
||||||
int rlag; /**< Replication Lag for Master / Slave replication */
|
int rlag; /**< Replication Lag for Master / Slave replication */
|
||||||
unsigned long node_ts; /**< Last timestamp set from M/S monitor module */
|
unsigned long node_ts; /**< Last timestamp set from M/S monitor module */
|
||||||
@ -311,6 +322,7 @@ extern void server_update_address(SERVER *server, const char *address);
|
|||||||
extern void server_update_port(SERVER *server, unsigned short port);
|
extern void server_update_port(SERVER *server, unsigned short port);
|
||||||
extern unsigned int server_map_status(const char *str);
|
extern unsigned int server_map_status(const char *str);
|
||||||
extern void server_set_version_string(SERVER* server, const char* string);
|
extern void server_set_version_string(SERVER* server, const char* string);
|
||||||
|
extern void server_set_version(SERVER* server, const char* string, uint32_t major, uint32_t minor, uint32_t patch);
|
||||||
extern void server_set_status(SERVER *server, int bit);
|
extern void server_set_status(SERVER *server, int bit);
|
||||||
extern void server_clear_status(SERVER *server, int bit);
|
extern void server_clear_status(SERVER *server, int bit);
|
||||||
|
|
||||||
|
|||||||
@ -1106,6 +1106,32 @@ void server_set_version_string(SERVER* server, const char* version)
|
|||||||
// be shorter than the old.
|
// be shorter than the old.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the version of the server.
|
||||||
|
*
|
||||||
|
* @param server Server to update
|
||||||
|
* @param string Human readable version string.
|
||||||
|
* @param major The major version.
|
||||||
|
* @param minor The minor version.
|
||||||
|
* @param patch The patch version.
|
||||||
|
*
|
||||||
|
* @return True if the assignment of the version string was successful, false if
|
||||||
|
* memory allocation failed.
|
||||||
|
*/
|
||||||
|
bool server_set_version(SERVER* server, const char* string, uint32_t major, uint32_t minor, uint32_t patch)
|
||||||
|
{
|
||||||
|
bool rv = server_set_version_string(server, string);
|
||||||
|
|
||||||
|
if (rv)
|
||||||
|
{
|
||||||
|
server->version.major = major;
|
||||||
|
server->version.minor = minor;
|
||||||
|
server->version.patch = patch;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a server configuration at the location pointed by @c filename
|
* Creates a server configuration at the location pointed by @c filename
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user