MXS-1249: Qc, the server version is passed as a single integer

To be compatible with how the version is managed elsewhere.
This commit is contained in:
Johan Wikman
2017-06-19 15:08:10 +03:00
parent 997416ab82
commit dcfe118457
4 changed files with 34 additions and 38 deletions

View File

@ -379,21 +379,19 @@ typedef struct query_classifier
* is classified. Note that the server version is maintained separately * is classified. Note that the server version is maintained separately
* for each thread. * for each thread.
* *
* @param major The major version. * @param version Version encoded as MariaDB encodes the version, i.e.:
* @param minor The minor version. * version = major * 10000 + minor * 100 + patch
* @param patch The patch version.
*/ */
void (*qc_set_server_version)(uint32_t major, uint32_t minor, uint32_t patch); void (*qc_set_server_version)(uint64_t version);
/** /**
* Get the thread specific version assumed of the server. If the version has * Get the thread specific version assumed of the server. If the version has
* not been set, all values are 0. * not been set, all values are 0.
* *
* @param major The major version. * @param version The version encoded as MariaDB encodes the version, i.e.:
* @param minor The minor version. * version = major * 10000 + minor * 100 + patch
* @param patch The patch version.
*/ */
void (*qc_get_server_version)(uint32_t* major, uint32_t* minor, uint32_t* patch); void (*qc_get_server_version)(uint64_t* version);
} QUERY_CLASSIFIER; } QUERY_CLASSIFIER;
/** /**
@ -784,20 +782,18 @@ char* qc_typemask_to_string(uint32_t typemask);
* is classified. Note that the server version is maintained separately * is classified. Note that the server version is maintained separately
* for each thread. * for each thread.
* *
* @param major The major version. * @param version Version encoded as MariaDB encodes the version, i.e.:
* @param minor The minor version. * version = major * 10000 + minor * 100 + patch
* @param patch The patch version.
*/ */
void qc_set_server_version(uint32_t major, uint32_t minor, uint32_t patch); void qc_set_server_version(uint64_t version);
/** /**
* Get the thread specific version assumed of the server. If the version has * Get the thread specific version assumed of the server. If the version has
* not been set, all values are 0. * not been set, all values are 0.
* *
* @param major The major version. * @return The version as MariaDB encodes the version, i.e:
* @param minor The minor version. * version = major * 10000 + minor * 100 + patch
* @param patch The patch version.
*/ */
void qc_get_server_version(uint32_t* major, uint32_t* minor, uint32_t* patch); uint64_t qc_get_server_version();
MXS_END_DECLS MXS_END_DECLS

View File

@ -99,9 +99,7 @@ static thread_local struct
// The version information is not used; the embedded library parses according // The version information is not used; the embedded library parses according
// to the version of the embedded library it has been linked with. However, we // to the version of the embedded library it has been linked with. However, we
// need to store the information so that qc_[get|set]_server_version will work. // need to store the information so that qc_[get|set]_server_version will work.
uint32_t version_major; uint64_t version;
uint32_t version_minor;
uint32_t version_patch;
} this_thread; } this_thread;
#define QTYPE_LESS_RESTRICTIVE_THAN_WRITE(t) (t<QUERY_TYPE_WRITE ? true : false) #define QTYPE_LESS_RESTRICTIVE_THAN_WRITE(t) (t<QUERY_TYPE_WRITE ? true : false)
@ -2600,18 +2598,14 @@ int32_t qc_mysql_get_function_info(GWBUF* buf,
return QC_RESULT_OK; return QC_RESULT_OK;
} }
void qc_mysql_set_server_version(uint32_t major, uint32_t minor, uint32_t patch) void qc_mysql_set_server_version(uint64_t version)
{ {
this_thread.version_major = major; this_thread.version = version;
this_thread.version_minor = minor;
this_thread.version_patch = patch;
} }
void qc_mysql_get_server_version(uint32_t* major, uint32_t* minor, uint32_t* patch) void qc_mysql_get_server_version(uint64_t* version)
{ {
*major = this_thread.version_major; *version = this_thread.version;
*minor = this_thread.version_minor;
*patch = this_thread.version_patch;
} }
namespace namespace

View File

@ -2910,8 +2910,8 @@ static int32_t qc_sqlite_get_canonical(GWBUF* query, char** canonical);
static int32_t qc_sqlite_query_has_clause(GWBUF* query, int32_t* has_clause); static int32_t qc_sqlite_query_has_clause(GWBUF* query, int32_t* has_clause);
static int32_t qc_sqlite_get_database_names(GWBUF* query, char*** names, int* sizep); static int32_t qc_sqlite_get_database_names(GWBUF* query, char*** names, int* sizep);
static int32_t qc_sqlite_get_preparable_stmt(GWBUF* stmt, GWBUF** preparable_stmt); static int32_t qc_sqlite_get_preparable_stmt(GWBUF* stmt, GWBUF** preparable_stmt);
static void qc_sqlite_set_server_version(uint32_t major, uint32_t minor, uint32_t patch); static void qc_sqlite_set_server_version(uint64_t version);
static void qc_sqlite_get_server_version(uint32_t* major, uint32_t* minor, uint32_t* patch); static void qc_sqlite_get_server_version(uint64_t* version);
static bool get_key_and_value(char* arg, const char** pkey, const char** pvalue) static bool get_key_and_value(char* arg, const char** pkey, const char** pvalue)
{ {
@ -3530,22 +3530,24 @@ int32_t qc_sqlite_get_preparable_stmt(GWBUF* stmt, GWBUF** preparable_stmt)
return rv; return rv;
} }
static void qc_sqlite_set_server_version(uint32_t major, uint32_t minor, uint32_t patch) static void qc_sqlite_set_server_version(uint64_t version)
{ {
QC_TRACE(); QC_TRACE();
uint32_t major = version / 10000;
uint32_t minor = (version - major * 10000) / 100;
uint32_t patch = version - major * 10000 - minor * 100;
this_thread.version_major = major; this_thread.version_major = major;
this_thread.version_minor = minor; this_thread.version_minor = minor;
this_thread.version_patch = patch; this_thread.version_patch = patch;
} }
static void qc_sqlite_get_server_version(uint32_t* major, uint32_t* minor, uint32_t* patch) static void qc_sqlite_get_server_version(uint64_t* version)
{ {
QC_TRACE(); QC_TRACE();
*major = this_thread.version_major; *version = this_thread.version_major * 10000 + this_thread.version_minor * 100 + this_thread.version_patch;
*minor = this_thread.version_minor;
*patch = this_thread.version_patch;
} }
/** /**

View File

@ -902,18 +902,22 @@ uint32_t qc_get_trx_type_mask(GWBUF* stmt)
return qc_get_trx_type_mask_using(stmt, qc_trx_parse_using); return qc_get_trx_type_mask_using(stmt, qc_trx_parse_using);
} }
void qc_set_server_version(uint32_t major, uint32_t minor, uint32_t patch) void qc_set_server_version(uint64_t version)
{ {
QC_TRACE(); QC_TRACE();
ss_dassert(classifier); ss_dassert(classifier);
classifier->qc_set_server_version(major, minor, patch); classifier->qc_set_server_version(version);
} }
void qc_get_server_version(uint32_t* major, uint32_t* minor, uint32_t* patch) uint64_t qc_get_server_version()
{ {
QC_TRACE(); QC_TRACE();
ss_dassert(classifier); ss_dassert(classifier);
classifier->qc_get_server_version(major, minor, patch); uint64_t version;
classifier->qc_get_server_version(&version);
return version;
} }