QC: Remove qc_is_real_query
Not used.
This commit is contained in:
parent
cd147add5f
commit
0ce7632f57
@ -151,7 +151,6 @@ typedef struct query_classifier
|
||||
|
||||
char* (*qc_get_created_table_name)(GWBUF* stmt);
|
||||
bool (*qc_is_drop_table_query)(GWBUF* stmt);
|
||||
bool (*qc_is_real_query)(GWBUF* stmt);
|
||||
char** (*qc_get_table_names)(GWBUF* stmt, int* tblsize, bool fullnames);
|
||||
char* (*qc_get_canonical)(GWBUF* stmt);
|
||||
bool (*qc_query_has_clause)(GWBUF* stmt);
|
||||
@ -436,21 +435,6 @@ uint32_t qc_get_type(GWBUF* stmt);
|
||||
*/
|
||||
bool qc_is_drop_table_query(GWBUF* stmt);
|
||||
|
||||
/**
|
||||
* Returns whether the statement is a "real" statement. Statements that affect
|
||||
* the underlying database are considered real statements, while statements that
|
||||
* target specific rows or variable data are regarded as real statement. That is,
|
||||
* a real statement is SELECT, UPDATE, INSERT, DELETE or a variation thereof.
|
||||
*
|
||||
* @param stmt A buffer containing a COM_QUERY.
|
||||
*
|
||||
* @return True if the statement is a real query, false otherwise.
|
||||
*
|
||||
* @todo Consider whether the function name should be changed or the function
|
||||
* removed altogether.
|
||||
*/
|
||||
bool qc_is_real_query(GWBUF* stmt);
|
||||
|
||||
/**
|
||||
* Returns the string representation of a query operation.
|
||||
*
|
||||
|
@ -36,11 +36,6 @@ char* qc_get_created_table_name(GWBUF* querybuf)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool qc_is_real_query(GWBUF* querybuf)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool qc_is_drop_table_query(GWBUF* querybuf)
|
||||
{
|
||||
return false;
|
||||
@ -117,7 +112,6 @@ extern "C"
|
||||
qc_get_operation,
|
||||
qc_get_created_table_name,
|
||||
qc_is_drop_table_query,
|
||||
qc_is_real_query,
|
||||
qc_get_table_names,
|
||||
NULL,
|
||||
qc_query_has_clause,
|
||||
|
@ -1379,61 +1379,6 @@ char* qc_get_created_table_name(GWBUF* querybuf)
|
||||
return table_name;
|
||||
}
|
||||
|
||||
bool qc_is_real_query(GWBUF* querybuf)
|
||||
{
|
||||
bool succp;
|
||||
LEX* lex;
|
||||
|
||||
if (querybuf == NULL)
|
||||
{
|
||||
succp = false;
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
if (!ensure_query_is_parsed(querybuf))
|
||||
{
|
||||
succp = false;
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
if ((lex = get_lex(querybuf)) == NULL)
|
||||
{
|
||||
succp = false;
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
switch (lex->sql_command)
|
||||
{
|
||||
case SQLCOM_SELECT:
|
||||
succp = lex->all_selects_list->table_list.elements > 0;
|
||||
goto retblock;
|
||||
break;
|
||||
|
||||
case SQLCOM_UPDATE_MULTI:
|
||||
case SQLCOM_UPDATE:
|
||||
case SQLCOM_INSERT:
|
||||
case SQLCOM_INSERT_SELECT:
|
||||
case SQLCOM_DELETE:
|
||||
case SQLCOM_DELETE_MULTI:
|
||||
case SQLCOM_TRUNCATE:
|
||||
case SQLCOM_REPLACE:
|
||||
case SQLCOM_REPLACE_SELECT:
|
||||
case SQLCOM_PREPARE:
|
||||
case SQLCOM_EXECUTE:
|
||||
succp = true;
|
||||
goto retblock;
|
||||
break;
|
||||
|
||||
default:
|
||||
succp = false;
|
||||
goto retblock;
|
||||
break;
|
||||
}
|
||||
|
||||
retblock:
|
||||
return succp;
|
||||
}
|
||||
|
||||
bool qc_is_drop_table_query(GWBUF* querybuf)
|
||||
{
|
||||
bool answer = false;
|
||||
@ -2777,7 +2722,6 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
qc_get_operation,
|
||||
qc_get_created_table_name,
|
||||
qc_is_drop_table_query,
|
||||
qc_is_real_query,
|
||||
qc_get_table_names,
|
||||
NULL,
|
||||
qc_query_has_clause,
|
||||
|
@ -60,7 +60,6 @@ typedef struct qc_sqlite_info
|
||||
|
||||
uint32_t types; // The types of the query.
|
||||
qc_query_op_t operation; // The operation in question.
|
||||
bool is_real_query; // SELECT, UPDATE, INSERT, DELETE or a variation.
|
||||
bool has_clause; // Has WHERE or HAVING.
|
||||
char** table_names; // Array of table names used in the query.
|
||||
size_t table_names_len; // The used entries in table_names.
|
||||
@ -370,7 +369,6 @@ static QC_SQLITE_INFO* info_init(QC_SQLITE_INFO* info)
|
||||
|
||||
info->types = QUERY_TYPE_UNKNOWN;
|
||||
info->operation = QUERY_OP_UNDEFINED;
|
||||
info->is_real_query = false;
|
||||
info->has_clause = false;
|
||||
info->table_names = NULL;
|
||||
info->table_names_len = 0;
|
||||
@ -1176,7 +1174,6 @@ static void update_field_infos_from_select(QC_SQLITE_INFO* info,
|
||||
if (pSrc->a[i].zName)
|
||||
{
|
||||
update_names(info, pSrc->a[i].zDatabase, pSrc->a[i].zName);
|
||||
info->is_real_query = true;
|
||||
}
|
||||
|
||||
if (pSrc->a[i].pSelect)
|
||||
@ -1471,7 +1468,6 @@ void mxs_sqlite3CreateView(Parse *pParse, /* The parsing context */
|
||||
if (pSelect)
|
||||
{
|
||||
update_field_infos_from_select(info, pSelect, QC_USED_IN_SELECT, NULL);
|
||||
info->is_real_query = false;
|
||||
}
|
||||
|
||||
exposed_sqlite3ExprListDelete(pParse->db, pCNames);
|
||||
@ -1488,7 +1484,6 @@ void mxs_sqlite3DeleteFrom(Parse* pParse, SrcList* pTabList, Expr* pWhere, SrcLi
|
||||
info->status = QC_QUERY_PARSED;
|
||||
info->types = QUERY_TYPE_WRITE;
|
||||
info->operation = QUERY_OP_DELETE;
|
||||
info->is_real_query = true;
|
||||
info->has_clause = pWhere ? true : false;
|
||||
|
||||
if (pUsing)
|
||||
@ -1605,7 +1600,6 @@ void mxs_sqlite3EndTable(Parse *pParse, /* Parse context */
|
||||
if (pSelect)
|
||||
{
|
||||
update_field_infos_from_select(info, pSelect, QC_USED_IN_SELECT, NULL);
|
||||
info->is_real_query = false;
|
||||
}
|
||||
else if (pOldTable)
|
||||
{
|
||||
@ -1643,7 +1637,6 @@ void mxs_sqlite3Insert(Parse* pParse,
|
||||
info->status = QC_QUERY_PARSED;
|
||||
info->types = QUERY_TYPE_WRITE;
|
||||
info->operation = QUERY_OP_INSERT;
|
||||
info->is_real_query = true;
|
||||
ss_dassert(pTabList);
|
||||
ss_dassert(pTabList->nSrc >= 1);
|
||||
update_names_from_srclist(info, pTabList);
|
||||
@ -1782,7 +1775,6 @@ void mxs_sqlite3Update(Parse* pParse, SrcList* pTabList, ExprList* pChanges, Exp
|
||||
info->status = QC_QUERY_PARSED;
|
||||
info->types = QUERY_TYPE_WRITE;
|
||||
info->operation = QUERY_OP_UPDATE;
|
||||
info->is_real_query = true;
|
||||
update_names_from_srclist(info, pTabList);
|
||||
info->has_clause = (pWhere ? true : false);
|
||||
|
||||
@ -1958,7 +1950,6 @@ void maxscaleExecute(Parse* pParse, Token* pName)
|
||||
|
||||
info->status = QC_QUERY_PARSED;
|
||||
info->types = QUERY_TYPE_WRITE;
|
||||
info->is_real_query = true;
|
||||
|
||||
info->prepare_name = MXS_MALLOC(pName->n + 1);
|
||||
if (info->prepare_name)
|
||||
@ -2121,7 +2112,6 @@ void maxscaleKeyword(int token)
|
||||
info->status = QC_QUERY_TOKENIZED;
|
||||
info->types = QUERY_TYPE_WRITE;
|
||||
info->operation = QUERY_OP_DELETE;
|
||||
info->is_real_query = true;
|
||||
break;
|
||||
|
||||
case TK_DESC:
|
||||
@ -2138,7 +2128,6 @@ void maxscaleKeyword(int token)
|
||||
case TK_EXECUTE:
|
||||
info->status = QC_QUERY_TOKENIZED;
|
||||
info->types = QUERY_TYPE_WRITE;
|
||||
info->is_real_query = true;
|
||||
break;
|
||||
|
||||
case TK_EXPLAIN:
|
||||
@ -2160,7 +2149,6 @@ void maxscaleKeyword(int token)
|
||||
info->status = QC_QUERY_TOKENIZED;
|
||||
info->types = QUERY_TYPE_WRITE;
|
||||
info->operation = QUERY_OP_INSERT;
|
||||
info->is_real_query = true;
|
||||
break;
|
||||
|
||||
case TK_LOCK:
|
||||
@ -2171,14 +2159,12 @@ void maxscaleKeyword(int token)
|
||||
case TK_PREPARE:
|
||||
info->status = QC_QUERY_TOKENIZED;
|
||||
info->types = QUERY_TYPE_PREPARE_NAMED_STMT;
|
||||
info->is_real_query = true;
|
||||
break;
|
||||
|
||||
case TK_REPLACE:
|
||||
info->status = QC_QUERY_TOKENIZED;
|
||||
info->types = QUERY_TYPE_WRITE;
|
||||
info->operation = QUERY_OP_INSERT;
|
||||
info->is_real_query = true;
|
||||
break;
|
||||
|
||||
case TK_REVOKE:
|
||||
@ -2218,13 +2204,11 @@ void maxscaleKeyword(int token)
|
||||
info->status = QC_QUERY_TOKENIZED;
|
||||
info->types = QUERY_TYPE_WRITE;
|
||||
info->operation = QUERY_OP_UPDATE;
|
||||
info->is_real_query = true;
|
||||
break;
|
||||
|
||||
case TK_TRUNCATE:
|
||||
info->status = QC_QUERY_TOKENIZED;
|
||||
info->types = (QUERY_TYPE_WRITE | QUERY_TYPE_COMMIT);
|
||||
info->is_real_query = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -2336,7 +2320,6 @@ void maxscalePrepare(Parse* pParse, Token* pName, Token* pStmt)
|
||||
|
||||
info->status = QC_QUERY_PARSED;
|
||||
info->types = QUERY_TYPE_PREPARE_NAMED_STMT;
|
||||
info->is_real_query = true;
|
||||
|
||||
info->prepare_name = MXS_MALLOC(pName->n + 1);
|
||||
if (info->prepare_name)
|
||||
@ -2537,7 +2520,6 @@ void maxscaleSet(Parse* pParse, int scope, mxs_set_t kind, ExprList* pList)
|
||||
{
|
||||
update_field_infos_from_select(info, pValue->x.pSelect,
|
||||
QC_USED_IN_SUBSELECT, NULL);
|
||||
info->is_real_query = false; // TODO: This is what qc_mysqlembedded claims.
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2763,7 +2745,6 @@ void maxscaleTruncate(Parse* pParse, Token* pDatabase, Token* pName)
|
||||
info->status = QC_QUERY_PARSED;
|
||||
info->types = (QUERY_TYPE_WRITE | QUERY_TYPE_COMMIT);
|
||||
info->operation = QUERY_OP_TRUNCATE;
|
||||
info->is_real_query = true;
|
||||
|
||||
char* zDatabase;
|
||||
|
||||
@ -2811,7 +2792,6 @@ static uint32_t qc_sqlite_get_type(GWBUF* query);
|
||||
static qc_query_op_t qc_sqlite_get_operation(GWBUF* query);
|
||||
static char* qc_sqlite_get_created_table_name(GWBUF* query);
|
||||
static bool qc_sqlite_is_drop_table_query(GWBUF* query);
|
||||
static bool qc_sqlite_is_real_query(GWBUF* query);
|
||||
static char** qc_sqlite_get_table_names(GWBUF* query, int* tblsize, bool fullnames);
|
||||
static char* qc_sqlite_get_canonical(GWBUF* query);
|
||||
static bool qc_sqlite_query_has_clause(GWBUF* query);
|
||||
@ -3151,34 +3131,6 @@ static bool qc_sqlite_is_drop_table_query(GWBUF* query)
|
||||
return is_drop_table;
|
||||
}
|
||||
|
||||
static bool qc_sqlite_is_real_query(GWBUF* query)
|
||||
{
|
||||
QC_TRACE();
|
||||
ss_dassert(this_unit.initialized);
|
||||
ss_dassert(this_thread.initialized);
|
||||
|
||||
bool is_real_query = false;
|
||||
QC_SQLITE_INFO* info = get_query_info(query);
|
||||
|
||||
if (info)
|
||||
{
|
||||
if (qc_info_is_valid(info->status))
|
||||
{
|
||||
is_real_query = info->is_real_query;
|
||||
}
|
||||
else if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
||||
{
|
||||
log_invalid_data(query, "cannot report whether query is a real query");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("The query could not be parsed. Response not valid.");
|
||||
}
|
||||
|
||||
return is_real_query;
|
||||
}
|
||||
|
||||
static char** qc_sqlite_get_table_names(GWBUF* query, int* tblsize, bool fullnames)
|
||||
{
|
||||
QC_TRACE();
|
||||
@ -3432,7 +3384,6 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
qc_sqlite_get_operation,
|
||||
qc_sqlite_get_created_table_name,
|
||||
qc_sqlite_is_drop_table_query,
|
||||
qc_sqlite_is_real_query,
|
||||
qc_sqlite_get_table_names,
|
||||
NULL,
|
||||
qc_sqlite_query_has_clause,
|
||||
|
@ -494,33 +494,6 @@ bool compare_is_drop_table_query(QUERY_CLASSIFIER* pClassifier1, GWBUF* pCopy1,
|
||||
return success;
|
||||
}
|
||||
|
||||
bool compare_is_real_query(QUERY_CLASSIFIER* pClassifier1, GWBUF* pCopy1,
|
||||
QUERY_CLASSIFIER* pClassifier2, GWBUF* pCopy2)
|
||||
{
|
||||
bool success = false;
|
||||
const char HEADING[] = "qc_is_real_query : ";
|
||||
|
||||
bool rv1 = pClassifier1->qc_is_real_query(pCopy1);
|
||||
bool rv2 = pClassifier2->qc_is_real_query(pCopy2);
|
||||
|
||||
stringstream ss;
|
||||
ss << HEADING;
|
||||
|
||||
if (rv1 == rv2)
|
||||
{
|
||||
ss << "Ok : " << rv1;
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << "ERR: " << rv1 << " != " << rv2;
|
||||
}
|
||||
|
||||
report(success, ss.str());
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool compare_strings(const char* const* strings1, const char* const* strings2, int n)
|
||||
{
|
||||
for (int i = 0; i < n; ++i)
|
||||
@ -1201,7 +1174,6 @@ bool compare(QUERY_CLASSIFIER* pClassifier1, QUERY_CLASSIFIER* pClassifier2, con
|
||||
errors += !compare_get_operation(pClassifier1, pCopy1, pClassifier2, pCopy2);
|
||||
errors += !compare_get_created_table_name(pClassifier1, pCopy1, pClassifier2, pCopy2);
|
||||
errors += !compare_is_drop_table_query(pClassifier1, pCopy1, pClassifier2, pCopy2);
|
||||
errors += !compare_is_real_query(pClassifier1, pCopy1, pClassifier2, pCopy2);
|
||||
errors += !compare_get_table_names(pClassifier1, pCopy1, pClassifier2, pCopy2, false);
|
||||
errors += !compare_get_table_names(pClassifier1, pCopy1, pClassifier2, pCopy2, true);
|
||||
errors += !compare_query_has_clause(pClassifier1, pCopy1, pClassifier2, pCopy2);
|
||||
|
@ -161,14 +161,6 @@ bool qc_is_drop_table_query(GWBUF* query)
|
||||
return classifier->qc_is_drop_table_query(query);
|
||||
}
|
||||
|
||||
bool qc_is_real_query(GWBUF* query)
|
||||
{
|
||||
QC_TRACE();
|
||||
ss_dassert(classifier);
|
||||
|
||||
return classifier->qc_is_real_query(query);
|
||||
}
|
||||
|
||||
char** qc_get_table_names(GWBUF* query, int* tblsize, bool fullnames)
|
||||
{
|
||||
QC_TRACE();
|
||||
|
Loading…
x
Reference in New Issue
Block a user