qc: Some minor cleanup
- qc_types_to_string renamed to qc_typemask_to_string - qc_get_qtype_str removed, duplicate of qc_typemask_to_string
This commit is contained in:
@ -212,56 +212,6 @@ bool qc_query_has_clause(GWBUF* query)
|
||||
return classifier->qc_query_has_clause(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a string of query type value.
|
||||
* Caller must free the memory of the resulting string.
|
||||
*
|
||||
* @param qtype Query type value, combination of values listed in
|
||||
* query_classifier.h
|
||||
*
|
||||
* @return string representing the query type value
|
||||
*/
|
||||
char* qc_get_qtype_str(qc_query_type_t qtype)
|
||||
{
|
||||
QC_TRACE();
|
||||
int t1 = (int) qtype;
|
||||
int t2 = 1;
|
||||
qc_query_type_t t = QUERY_TYPE_UNKNOWN;
|
||||
char* qtype_str = NULL;
|
||||
|
||||
/**
|
||||
* Test values (bits) and clear matching bits from t1 one by one until
|
||||
* t1 is completely cleared.
|
||||
*/
|
||||
while (t1 != 0)
|
||||
{
|
||||
if (t1 & t2)
|
||||
{
|
||||
t = (qc_query_type_t) t2;
|
||||
|
||||
if (qtype_str == NULL)
|
||||
{
|
||||
qtype_str = MXS_STRDUP_A(STRQTYPE(t));
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t len = strlen(STRQTYPE(t));
|
||||
/** reallocate space for delimiter, new string and termination */
|
||||
qtype_str = (char *) MXS_REALLOC(qtype_str, strlen(qtype_str) + 1 + len + 1);
|
||||
MXS_ABORT_IF_NULL(qtype_str);
|
||||
snprintf(qtype_str + strlen(qtype_str), 1 + len + 1, "|%s", STRQTYPE(t));
|
||||
}
|
||||
|
||||
/** Remove found value from t1 */
|
||||
t1 &= ~t2;
|
||||
}
|
||||
|
||||
t2 <<= 1;
|
||||
}
|
||||
|
||||
return qtype_str;
|
||||
}
|
||||
|
||||
char* qc_get_affected_fields(GWBUF* query)
|
||||
{
|
||||
QC_TRACE();
|
||||
@ -595,7 +545,7 @@ static const int QUERY_TYPE_MAX_LEN = 29; // strlen("QUERY_TYPE_PREPARE_NAMED_ST
|
||||
* NOTE: The returned string is dynamically allocated
|
||||
* and *must* be freed by the caller.
|
||||
*/
|
||||
char* qc_types_to_string(uint32_t types)
|
||||
char* qc_typemask_to_string(uint32_t types)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user