blerer commented on a change in pull request #1369:
URL: https://github.com/apache/cassandra/pull/1369#discussion_r773725544
##########
File path: src/java/org/apache/cassandra/cql3/QueryProcessor.java
##########
@@ -638,11 +640,30 @@ public static CQLStatement getStatement(String queryStr,
ClientState clientState
// Set keyspace for statement that require login
if (statement instanceof QualifiedStatement)
((QualifiedStatement) statement).setKeyspace(clientState);
+ logger.info(String.format("Statement is: %s", statement.toString()));
+ if (instance.isDDLStatement(queryStr)){
+ logger.info(String.format("DDL Query: %s, by User: %s, From: %s",
+ queryStr,
+ clientState.getUser(),
+
clientState.getRemoteAddress().getAddress()));
Review comment:
If the `ClientState` is internal (queries triggered by C* itself)
`getRemoteAddress()` will return `null` and the `getAddress()` call will
trigger a NPE.
If authentication is disable the user will be null whic can look weird in
the error message. We should probably create a `toString `method in
`ClientState` that take those things into account and rely on that method for
the additional information.
What do you think?
##########
File path: src/java/org/apache/cassandra/cql3/QueryProcessor.java
##########
@@ -638,11 +640,30 @@ public static CQLStatement getStatement(String queryStr,
ClientState clientState
// Set keyspace for statement that require login
if (statement instanceof QualifiedStatement)
((QualifiedStatement) statement).setKeyspace(clientState);
+ logger.info(String.format("Statement is: %s", statement.toString()));
+ if (instance.isDDLStatement(queryStr)){
+ logger.info(String.format("DDL Query: %s, by User: %s, From: %s",
+ queryStr,
+ clientState.getUser(),
+
clientState.getRemoteAddress().getAddress()));
+ }
Tracing.trace("Preparing statement");
return statement.prepare(clientState);
}
+ public boolean isDDLStatement(String queryStr)
+ {
+ for (final String ddlStmt : DDL_STATEMENTS)
+ {
+ if (queryStr.toUpperCase().startsWith(ddlStmt))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
Review comment:
All the DDL statements extends {{AlterSchemaStatement}}, you can rely on
an `instanceof` check. :-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]