MXS-3121 Expose statement currently being classified
Intended to be used from fatal signal handlers. As the statement will be returned only while classification is in process, if a statement is returned, it is an indication that the crash was caused by the classification.
This commit is contained in:
parent
bf6ff8a578
commit
c5870cbaba
@ -469,6 +469,19 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK if @c options is valid, otherwise QC_RESULT_ERROR.
|
||||
*/
|
||||
int32_t (* qc_set_options)(uint32_t options);
|
||||
|
||||
/**
|
||||
* Return statement currently being classified.
|
||||
*
|
||||
* @param ppStmp Pointer to pointer that on return will point to the
|
||||
* statement being classified.
|
||||
* @param pLen Pointer to value that on return will contain the length
|
||||
* of the returned string.
|
||||
*
|
||||
* @return QC_RESULT_OK if a statement was returned (i.e. a statement is being
|
||||
* classified), QC_RESULT_ERROR otherwise.
|
||||
*/
|
||||
int32_t (* qc_get_current_stmt)(const char** ppStmt, size_t* pLen);
|
||||
} QUERY_CLASSIFIER;
|
||||
|
||||
/**
|
||||
@ -996,4 +1009,21 @@ uint32_t qc_get_options();
|
||||
*/
|
||||
bool qc_set_options(uint32_t options);
|
||||
|
||||
/**
|
||||
* Return statement currently being classified.
|
||||
*
|
||||
* @param ppStmp Pointer to pointer that on return will point to the
|
||||
* statement being classified.
|
||||
* @param pLen Pointer to value that on return will contain the length
|
||||
* of the returned string.
|
||||
*
|
||||
* @return True, if a statement was returned (i.e. a statement is being
|
||||
* classified), false otherwise.
|
||||
*
|
||||
* @note A string /may/ be returned /only/ when this function is called from
|
||||
* a signal handler that is called due to the classifier causing
|
||||
* a crash.
|
||||
*/
|
||||
bool qc_get_current_stmt(const char** ppStmt, size_t* pLen);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
@ -3648,6 +3648,12 @@ int32_t qc_mysql_set_options(uint32_t options)
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32_t qc_mysql_get_current_stmt(const char** ppStmt, size_t* pLen)
|
||||
{
|
||||
return QC_RESULT_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* EXPORTS
|
||||
*/
|
||||
@ -3684,7 +3690,8 @@ extern "C"
|
||||
nullptr, // qc_info_dup not supported.
|
||||
nullptr, // qc_info_close not supported.
|
||||
qc_mysql_get_options,
|
||||
qc_mysql_set_options
|
||||
qc_mysql_set_options,
|
||||
qc_mysql_get_current_stmt
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
@ -5359,6 +5359,20 @@ int32_t qc_sqlite_set_options(uint32_t options)
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32_t qc_sqlite_get_current_stmt(const char** ppStmt, size_t* pLen)
|
||||
{
|
||||
int32_t rv = QC_RESULT_ERROR;
|
||||
|
||||
if (this_thread.pInfo && this_thread.pInfo->m_pQuery && (this_thread.pInfo->m_nQuery != 0))
|
||||
{
|
||||
*ppStmt = this_thread.pInfo->m_pQuery;
|
||||
*pLen = this_thread.pInfo->m_nQuery;
|
||||
rv = QC_RESULT_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* EXPORTS
|
||||
*/
|
||||
@ -5395,7 +5409,8 @@ extern "C"
|
||||
qc_sqlite_info_dup,
|
||||
qc_sqlite_info_close,
|
||||
qc_sqlite_get_options,
|
||||
qc_sqlite_set_options
|
||||
qc_sqlite_set_options,
|
||||
qc_sqlite_get_current_stmt
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
@ -1313,6 +1313,14 @@ bool qc_set_options(uint32_t options)
|
||||
return rv == QC_RESULT_OK;
|
||||
}
|
||||
|
||||
bool qc_get_current_stmt(const char** ppStmt, size_t* pLen)
|
||||
{
|
||||
QC_TRACE();
|
||||
mxb_assert(this_unit.classifier);
|
||||
|
||||
return this_unit.classifier->qc_get_current_stmt(ppStmt, pLen) == QC_RESULT_OK;
|
||||
}
|
||||
|
||||
void qc_get_cache_properties(QC_CACHE_PROPERTIES* properties)
|
||||
{
|
||||
properties->max_size = this_unit.cache_max_size();
|
||||
|
Loading…
x
Reference in New Issue
Block a user