MXS-1249: Qc, allow setting the server version
In the case of qc_sqlite, the server version may affect how statements are parsed.
This commit is contained in:
@ -94,6 +94,16 @@ typedef struct parsing_info_st
|
||||
#endif
|
||||
} parsing_info_t;
|
||||
|
||||
static thread_local struct
|
||||
{
|
||||
// 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
|
||||
// need to store the information so that qc_[get|set]_server_version will work.
|
||||
uint32_t version_major;
|
||||
uint32_t version_minor;
|
||||
uint32_t version_patch;
|
||||
} this_thread;
|
||||
|
||||
#define QTYPE_LESS_RESTRICTIVE_THAN_WRITE(t) (t<QUERY_TYPE_WRITE ? true : false)
|
||||
|
||||
static THD* get_or_create_thd_for_parsing(MYSQL* mysql, char* query_str);
|
||||
@ -2590,6 +2600,20 @@ int32_t qc_mysql_get_function_info(GWBUF* buf,
|
||||
return QC_RESULT_OK;
|
||||
}
|
||||
|
||||
void qc_mysql_set_server_version(uint32_t major, uint32_t minor, uint32_t patch)
|
||||
{
|
||||
this_thread.version_major = major;
|
||||
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)
|
||||
{
|
||||
*major = this_thread.version_major;
|
||||
*minor = this_thread.version_minor;
|
||||
*patch = this_thread.version_patch;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -2743,6 +2767,8 @@ extern "C"
|
||||
qc_mysql_get_field_info,
|
||||
qc_mysql_get_function_info,
|
||||
qc_mysql_get_preparable_stmt,
|
||||
qc_mysql_set_server_version,
|
||||
qc_mysql_get_server_version,
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
@ -114,6 +114,9 @@ static thread_local struct
|
||||
bool initialized;
|
||||
sqlite3* db; // Thread specific database handle.
|
||||
QC_SQLITE_INFO* info;
|
||||
uint32_t version_major;
|
||||
uint32_t version_minor;
|
||||
uint32_t version_patch;
|
||||
} this_thread;
|
||||
|
||||
/**
|
||||
@ -2907,6 +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_get_database_names(GWBUF* query, char*** names, int* sizep);
|
||||
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_get_server_version(uint32_t* major, uint32_t* minor, uint32_t* patch);
|
||||
|
||||
static bool get_key_and_value(char* arg, const char** pkey, const char** pvalue)
|
||||
{
|
||||
@ -3080,6 +3085,9 @@ static int32_t qc_sqlite_thread_init(void)
|
||||
this_thread.info = NULL;
|
||||
|
||||
this_thread.initialized = true;
|
||||
this_thread.version_major = 0;
|
||||
this_thread.version_minor = 0;
|
||||
this_thread.version_patch = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3522,6 +3530,24 @@ int32_t qc_sqlite_get_preparable_stmt(GWBUF* stmt, GWBUF** preparable_stmt)
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void qc_sqlite_set_server_version(uint32_t major, uint32_t minor, uint32_t patch)
|
||||
{
|
||||
QC_TRACE();
|
||||
|
||||
this_thread.version_major = major;
|
||||
this_thread.version_minor = minor;
|
||||
this_thread.version_patch = patch;
|
||||
}
|
||||
|
||||
static void qc_sqlite_get_server_version(uint32_t* major, uint32_t* minor, uint32_t* patch)
|
||||
{
|
||||
QC_TRACE();
|
||||
|
||||
*major = this_thread.version_major;
|
||||
*minor = this_thread.version_minor;
|
||||
*patch = this_thread.version_patch;
|
||||
}
|
||||
|
||||
/**
|
||||
* EXPORTS
|
||||
*/
|
||||
@ -3548,6 +3574,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
qc_sqlite_get_field_info,
|
||||
qc_sqlite_get_function_info,
|
||||
qc_sqlite_get_preparable_stmt,
|
||||
qc_sqlite_set_server_version,
|
||||
qc_sqlite_get_server_version,
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
Reference in New Issue
Block a user