Make it possible to specify query classifier name.

If none provided or if the name is empty, the default query
classifier is loaded.
This commit is contained in:
Johan Wikman
2016-02-01 19:46:16 +02:00
parent 72f02164fc
commit bbfcbc18c6
3 changed files with 11 additions and 6 deletions

View File

@ -40,24 +40,29 @@ static const char default_qc_name[] = "qc_mysqlembedded";
static QUERY_CLASSIFIER* classifier; static QUERY_CLASSIFIER* classifier;
bool qc_init(void) bool qc_init(const char* plugin_name)
{ {
QC_TRACE(); QC_TRACE();
ss_dassert(!classifier); ss_dassert(!classifier);
if (!plugin_name || (*plugin_name == 0))
{
plugin_name = default_qc_name;
}
bool success = false; bool success = false;
void* module = load_module(default_qc_name, MODULE_QUERY_CLASSIFIER); void* module = load_module(plugin_name, MODULE_QUERY_CLASSIFIER);
if (module) if (module)
{ {
classifier = (QUERY_CLASSIFIER*) module; classifier = (QUERY_CLASSIFIER*) module;
MXS_NOTICE("%s loaded.", default_qc_name); MXS_NOTICE("%s loaded.", plugin_name);
success = classifier->qc_init(); success = classifier->qc_init();
} }
else else
{ {
MXS_ERROR("Could not load %s.", default_qc_name); MXS_ERROR("Could not load %s.", plugin_name);
} }
return success; return success;

View File

@ -74,7 +74,7 @@ typedef enum
#define QUERY_IS_TYPE(mask,type) ((mask & type) == type) #define QUERY_IS_TYPE(mask,type) ((mask & type) == type)
bool qc_init(void); bool qc_init(const char* plugin_name);
void qc_end(void); void qc_end(void);
bool qc_thread_init(void); bool qc_thread_init(void);

View File

@ -1769,7 +1769,7 @@ int main(int argc, char **argv)
MXS_NOTICE("Module directory: %s", get_libdir()); MXS_NOTICE("Module directory: %s", get_libdir());
MXS_NOTICE("Service cache: %s", get_cachedir()); MXS_NOTICE("Service cache: %s", get_cachedir());
if (!qc_init()) if (!qc_init(NULL))
{ {
char* logerr = "Failed to initialise query classifier library."; char* logerr = "Failed to initialise query classifier library.";
print_log_n_stderr(true, true, logerr, logerr, eno); print_log_n_stderr(true, true, logerr, logerr, eno);