MXS-1406 Report CALL operation

Basically it would be trivial to report far more operations
explicitly, but for the fact that the values in qc_query_op_t
currently, quite unnecessarily, form a bitmask.

In 2.2 that is no longer the case, so other operations will be
added there.
This commit is contained in:
Johan Wikman
2017-09-12 15:38:25 +03:00
parent 362234b5d2
commit 49ab5797a2
6 changed files with 27 additions and 18 deletions

View File

@ -94,7 +94,8 @@ typedef enum qc_query_op
QUERY_OP_CHANGE_DB = (1 << 8), QUERY_OP_CHANGE_DB = (1 << 8),
QUERY_OP_LOAD = (1 << 9), QUERY_OP_LOAD = (1 << 9),
QUERY_OP_GRANT = (1 << 10), QUERY_OP_GRANT = (1 << 10),
QUERY_OP_REVOKE = (1 << 11) QUERY_OP_REVOKE = (1 << 11),
QUERY_OP_CALL = (1 << 12),
} qc_query_op_t; } qc_query_op_t;
/** /**

View File

@ -1737,6 +1737,10 @@ int32_t qc_mysql_get_operation(GWBUF* querybuf, int32_t* operation)
*operation = QUERY_OP_REVOKE; *operation = QUERY_OP_REVOKE;
break; break;
case SQLCOM_CALL:
*operation = QUERY_OP_CALL;
break;
default: default:
*operation = QUERY_OP_UNDEFINED; *operation = QUERY_OP_UNDEFINED;
} }

View File

@ -1946,7 +1946,7 @@ void maxscaleAlterTable(Parse *pParse, /* Parser context. */
exposed_sqlite3SrcListDelete(pParse->db, pSrc); exposed_sqlite3SrcListDelete(pParse->db, pSrc);
} }
void maxscaleCall(Parse* pParse, SrcList* pName) void maxscaleCall(Parse* pParse, SrcList* pName, ExprList* pExprList)
{ {
QC_TRACE(); QC_TRACE();
@ -1955,8 +1955,15 @@ void maxscaleCall(Parse* pParse, SrcList* pName)
info->status = QC_QUERY_PARSED; info->status = QC_QUERY_PARSED;
info->type_mask = QUERY_TYPE_WRITE; info->type_mask = QUERY_TYPE_WRITE;
info->operation = QUERY_OP_CALL;
if (pExprList)
{
update_field_infos_from_exprlist(info, pExprList, 0, NULL);
}
exposed_sqlite3SrcListDelete(pParse->db, pName); exposed_sqlite3SrcListDelete(pParse->db, pName);
exposed_sqlite3ExprListDelete(pParse->db, pExprList);
} }
void maxscaleCheckTable(Parse* pParse, SrcList* pTables) void maxscaleCheckTable(Parse* pParse, SrcList* pTables)

View File

@ -107,7 +107,7 @@ extern void mxs_sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
extern void maxscaleCollectInfoFromSelect(Parse*, Select*, int); extern void maxscaleCollectInfoFromSelect(Parse*, Select*, int);
extern void maxscaleAlterTable(Parse*, mxs_alter_t command, SrcList*, Token*); extern void maxscaleAlterTable(Parse*, mxs_alter_t command, SrcList*, Token*);
extern void maxscaleCall(Parse*, SrcList* pName); extern void maxscaleCall(Parse*, SrcList* pName, ExprList* pExprList);
extern void maxscaleCheckTable(Parse*, SrcList* pTables); extern void maxscaleCheckTable(Parse*, SrcList* pTables);
extern void maxscaleDeallocate(Parse*, Token* pName); extern void maxscaleDeallocate(Parse*, Token* pName);
extern void maxscaleDo(Parse*, ExprList* pEList); extern void maxscaleDo(Parse*, ExprList* pEList);
@ -2691,21 +2691,12 @@ default_opt ::= DEFAULT.
// //
cmd ::= call. cmd ::= call.
call_arg ::= INTEGER. %type call_args_opt {ExprList*}
call_arg ::= FLOAT. call_args_opt(A) ::= . {A=0;}
call_arg ::= STRING. call_args_opt(A) ::= LP exprlist(X) RP. {A=X;}
call_arg ::= id.
call_arg ::= VARIABLE.
call_args ::= call_arg. call ::= CALL fullname(X) call_args_opt(Y). {
call_args ::= call_args COMMA call_arg. maxscaleCall(pParse, X, Y);
call_args_opt ::= .
call_args_opt ::= LP RP.
call_args_opt ::= LP call_args RP.
call ::= CALL fullname(X) call_args_opt. {
maxscaleCall(pParse, X);
} }
//////////////////////// DROP FUNCTION statement //////////////////////////////////// //////////////////////// DROP FUNCTION statement ////////////////////////////////////

View File

@ -84,3 +84,6 @@ select * from db1.t1 union select * from db2.t2;
# Names is a keyword as well # Names is a keyword as well
select names from t; select names from t;
call p1();
call p1(@var);

View File

@ -530,6 +530,9 @@ const char* qc_op_to_string(qc_query_op_t op)
case QUERY_OP_REVOKE: case QUERY_OP_REVOKE:
return "QUERY_OP_REVOKE"; return "QUERY_OP_REVOKE";
case QUERY_OP_CALL:
return "QUERY_OP_CALL";
default: default:
return "UNKNOWN_QUERY_OP"; return "UNKNOWN_QUERY_OP";
} }