Merge branch '2.3' into develop

This commit is contained in:
Johan Wikman
2019-05-03 13:48:57 +03:00
19 changed files with 517 additions and 21 deletions

View File

@ -96,9 +96,11 @@ class QCInfoCache;
static thread_local struct
{
QCInfoCache* pInfo_cache;
uint32_t options;
} this_thread =
{
nullptr
nullptr,
0
};
@ -147,7 +149,8 @@ public:
{
Entry& entry = i->second;
if (entry.sql_mode == this_unit.qc_sql_mode)
if ((entry.sql_mode == this_unit.qc_sql_mode) &&
(entry.options == this_thread.options))
{
mxb_assert(this_unit.classifier);
this_unit.classifier->qc_info_dup(entry.pInfo);
@ -158,7 +161,7 @@ public:
}
else
{
// If the sql_mode has changed, we discard the existing result.
// If the sql_mode or options has changed, we discard the existing result.
erase(i);
++m_stats.misses;
@ -198,7 +201,7 @@ public:
{
this_unit.classifier->qc_info_dup(pInfo);
m_infos.emplace(canonical_stmt, Entry(pInfo, this_unit.qc_sql_mode));
m_infos.emplace(canonical_stmt, Entry(pInfo, this_unit.qc_sql_mode, this_thread.options));
++m_stats.inserts;
m_stats.size += size;
@ -248,15 +251,17 @@ public:
private:
struct Entry
{
Entry(QC_STMT_INFO* pInfo, qc_sql_mode_t sql_mode)
Entry(QC_STMT_INFO* pInfo, qc_sql_mode_t sql_mode, uint32_t options)
: pInfo(pInfo)
, sql_mode(sql_mode)
, options(options)
, hits(0)
{
}
QC_STMT_INFO* pInfo;
qc_sql_mode_t sql_mode;
uint32_t options;
int64_t hits;
};
@ -1319,6 +1324,29 @@ void qc_set_sql_mode(qc_sql_mode_t sql_mode)
}
}
uint32_t qc_get_options()
{
QC_TRACE();
mxb_assert(this_unit.classifier);
return this_unit.classifier->qc_get_options();
}
bool qc_set_options(uint32_t options)
{
QC_TRACE();
mxb_assert(this_unit.classifier);
int32_t rv = this_unit.classifier->qc_set_options(options);
if (rv == QC_RESULT_OK)
{
this_thread.options = options;
}
return rv == QC_RESULT_OK;
}
void qc_get_cache_properties(QC_CACHE_PROPERTIES* properties)
{
properties->max_size = this_unit.cache_max_size();
@ -1330,6 +1358,11 @@ bool qc_set_cache_properties(const QC_CACHE_PROPERTIES* properties)
if (properties->max_size >= 0)
{
if (properties->max_size == 0)
{
MXS_NOTICE("Query classifier cache disabled.");
}
this_unit.set_cache_max_size(properties->max_size);
rv = true;
}