MXS-1624 Update qc_setup() prototype
Now takes a structure that, if present, enables the query classification caching and specifies the properties of the cache. For the time being no actual properties are yet available.
This commit is contained in:
parent
b7c5abf73b
commit
e7913cc022
@ -434,6 +434,13 @@ typedef struct query_classifier
|
||||
void (*qc_info_close)(QC_STMT_INFO* info);
|
||||
} QUERY_CLASSIFIER;
|
||||
|
||||
/**
|
||||
* QC_CACHE specifies the limits of the query classification cache.
|
||||
*/
|
||||
typedef struct QC_CACHE_PROPERTIES
|
||||
{
|
||||
} QC_CACHE_PROPERTIES;
|
||||
|
||||
/**
|
||||
* Loads and sets up the default query classifier.
|
||||
*
|
||||
@ -443,9 +450,10 @@ typedef struct query_classifier
|
||||
*
|
||||
* MaxScale calls this function, so plugins should not do that.
|
||||
*
|
||||
* @param qc_cache If non-NULL, specifies the properties of the QC cache.
|
||||
* @param sql_mode The default sql mode.
|
||||
* @param plugin_name The name of the plugin from which the query classifier
|
||||
* should be loaded.
|
||||
* @param sql_mode The default sql mode.
|
||||
* @param plugin_args The arguments to be provided to the query classifier.
|
||||
*
|
||||
* @return True if the query classifier could be loaded and initialized,
|
||||
@ -453,7 +461,9 @@ typedef struct query_classifier
|
||||
*
|
||||
* @see qc_end qc_thread_init
|
||||
*/
|
||||
bool qc_setup(const char* plugin_name, qc_sql_mode_t sql_mode, const char* plugin_args);
|
||||
bool qc_setup(const QC_CACHE_PROPERTIES* cache_properties,
|
||||
qc_sql_mode_t sql_mode,
|
||||
const char* plugin_name, const char* plugin_args);
|
||||
|
||||
/**
|
||||
* Intializes the query classifier.
|
||||
|
@ -317,7 +317,7 @@ int main(int argc, char** argv)
|
||||
|
||||
if (mxs_log_init(NULL, ".", MXS_LOG_TARGET_DEFAULT))
|
||||
{
|
||||
if (qc_setup(lib, QC_SQL_MODE_DEFAULT, NULL) &&
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, lib, NULL) &&
|
||||
qc_process_init(QC_INIT_BOTH) &&
|
||||
qc_thread_init(QC_INIT_BOTH))
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ int main()
|
||||
|
||||
set_libdir(strdup("../qc_sqlite"));
|
||||
|
||||
if (qc_setup("qc_sqlite", QC_SQL_MODE_DEFAULT, NULL) &&
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, "qc_sqlite", NULL) &&
|
||||
qc_process_init(QC_INIT_BOTH) &&
|
||||
qc_thread_init(QC_INIT_BOTH))
|
||||
{
|
||||
|
@ -131,7 +131,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
set_libdir(strdup(LIBDIR));
|
||||
|
||||
if (qc_setup(QC_LIB, QC_SQL_MODE_DEFAULT, NULL))
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, QC_LIB, NULL))
|
||||
{
|
||||
if (qc_process_init(QC_INIT_BOTH) && qc_thread_init(QC_INIT_BOTH))
|
||||
{
|
||||
|
@ -1975,7 +1975,7 @@ int main(int argc, char **argv)
|
||||
goto return_main;
|
||||
}
|
||||
|
||||
if (!qc_setup(cnf->qc_name, cnf->qc_sql_mode, cnf->qc_args))
|
||||
if (!qc_setup(NULL, cnf->qc_sql_mode, cnf->qc_name, cnf->qc_args))
|
||||
{
|
||||
const char* logerr = "Failed to initialise query classifier library.";
|
||||
print_log_n_stderr(true, true, logerr, logerr, eno);
|
||||
|
@ -255,7 +255,9 @@ private:
|
||||
}
|
||||
|
||||
|
||||
bool qc_setup(const char* plugin_name, qc_sql_mode_t sql_mode, const char* plugin_args)
|
||||
bool qc_setup(const QC_CACHE_PROPERTIES* cache_properties,
|
||||
qc_sql_mode_t sql_mode,
|
||||
const char* plugin_name, const char* plugin_args)
|
||||
{
|
||||
QC_TRACE();
|
||||
ss_dassert(!this_unit.classifier);
|
||||
@ -276,6 +278,7 @@ bool qc_setup(const char* plugin_name, qc_sql_mode_t sql_mode, const char* plugi
|
||||
if (rv == QC_RESULT_OK)
|
||||
{
|
||||
this_unit.qc_sql_mode = sql_mode;
|
||||
this_unit.use_cached_result = (cache_properties ? true : false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ int main(int argc, char** argv)
|
||||
set_langdir(strdup("."));
|
||||
set_process_datadir(strdup("/tmp"));
|
||||
|
||||
qc_setup("qc_sqlite", QC_SQL_MODE_DEFAULT, NULL);
|
||||
qc_setup(NULL, QC_SQL_MODE_DEFAULT, "qc_sqlite", NULL);
|
||||
qc_process_init(QC_INIT_BOTH);
|
||||
qc_thread_init(QC_INIT_BOTH);
|
||||
|
||||
|
@ -186,7 +186,7 @@ int main(int argc, char* argv[])
|
||||
set_libdir(strdup("../../../query_classifier/qc_sqlite"));
|
||||
|
||||
// We have to setup something in order for the regexes to be compiled.
|
||||
if (qc_setup("qc_sqlite", QC_SQL_MODE_DEFAULT, NULL) &&
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, "qc_sqlite", NULL) &&
|
||||
qc_process_init(QC_INIT_BOTH) &&
|
||||
qc_thread_init(QC_INIT_BOTH))
|
||||
{
|
||||
|
@ -423,7 +423,7 @@ int main(int argc, char* argv[])
|
||||
set_libdir(strdup("../../../query_classifier/qc_sqlite"));
|
||||
|
||||
// We have to setup something in order for the regexes to be compiled.
|
||||
if (qc_setup("qc_sqlite", QC_SQL_MODE_DEFAULT, NULL) &&
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, "qc_sqlite", NULL) &&
|
||||
qc_process_init(QC_INIT_BOTH) &&
|
||||
qc_thread_init(QC_INIT_BOTH))
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ void init_test_env(char *path)
|
||||
}
|
||||
dcb_global_init();
|
||||
set_libdir(MXS_STRDUP(TEST_DIR "/query_classifier/qc_sqlite/"));
|
||||
qc_setup(NULL, QC_SQL_MODE_DEFAULT, NULL);
|
||||
qc_setup(NULL, QC_SQL_MODE_DEFAULT, NULL, NULL);
|
||||
qc_process_init(QC_INIT_BOTH);
|
||||
poll_init();
|
||||
maxscale::MessageQueue::init();
|
||||
|
@ -423,7 +423,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
if (mxs_log_init(NULL, ".", MXS_LOG_TARGET_DEFAULT))
|
||||
{
|
||||
if (qc_setup("qc_sqlite", QC_SQL_MODE_DEFAULT, NULL))
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, "qc_sqlite", NULL))
|
||||
{
|
||||
if (qc_process_init(QC_INIT_SELF))
|
||||
{
|
||||
|
@ -133,7 +133,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (mxs_log_init(NULL, ".", MXS_LOG_TARGET_DEFAULT))
|
||||
{
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, NULL) && qc_process_init(QC_INIT_BOTH))
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, NULL, NULL) && qc_process_init(QC_INIT_BOTH))
|
||||
{
|
||||
const char* zModule = argv[1];
|
||||
libdir = MXS_STRDUP("../storage/storage_inmemory/");
|
||||
|
@ -397,7 +397,7 @@ int main()
|
||||
pConfig->n_threads = 1;
|
||||
|
||||
set_libdir(MXS_STRDUP_A("../../../../../query_classifier/qc_sqlite/"));
|
||||
if (qc_setup("qc_sqlite", QC_SQL_MODE_DEFAULT, "") &&
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, "qc_sqlite", "") &&
|
||||
qc_process_init(QC_INIT_BOTH) &&
|
||||
qc_thread_init(QC_INIT_BOTH))
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ int TestStorage::run(int argc, char** argv)
|
||||
{
|
||||
if (mxs_log_init(NULL, ".", MXS_LOG_TARGET_DEFAULT))
|
||||
{
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, NULL) && qc_process_init(QC_INIT_BOTH))
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, NULL, NULL) && qc_process_init(QC_INIT_BOTH))
|
||||
{
|
||||
const char* zModule = NULL;
|
||||
size_t threads = m_threads;
|
||||
|
@ -995,7 +995,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
if (mxs_log_init(NULL, ".", MXS_LOG_TARGET_STDOUT))
|
||||
{
|
||||
if (qc_setup("qc_sqlite", QC_SQL_MODE_DEFAULT, NULL))
|
||||
if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, "qc_sqlite", NULL))
|
||||
{
|
||||
if (qc_process_init(QC_INIT_SELF))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user