tkalkirill commented on code in PR #13745:
URL: https://github.com/apache/ignite/pull/13745#discussion_r4493159798


##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/RootQuery.java:
##########
@@ -489,7 +489,10 @@ else if (state == QueryState.CLOSING)
             .append(", state=").append(state)
             .append(", schema=").append(ctx.schemaName())
             .append(", initiatorId=").append(initiatorId)
-            .append(", sql='").append(sql);
+            .append(", sql='").append(sql).append('\'');
+
+        if (QueryUtils.INCLUDE_SENSITIVE && params != null && params.length != 
0)

Review Comment:
   U can use `!F.isEmpty(params)`



##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlDiagnosticIntegrationTest.java:
##########
@@ -1040,6 +1040,39 @@ public void testSqlFieldsQueryWithInitiatorId() throws 
Exception {
         assertTrue(logLsnr.check(1000));
     }
 
+    /** Checks that query parameters are printed in the long query warning 
only when sensitive data is allowed. */
+    @Test
+    public void testLongQueryParametersInLog() throws Exception {
+        IgniteCache<Long, Long> cache = prepareTestCache(grid(0));
+
+        long arg = LONG_QRY_TIMEOUT + LONG_QRY_TIMEOUT / 2;
+
+        boolean includeSensitive = QueryUtils.INCLUDE_SENSITIVE;
+
+        try {
+            for (boolean incl : new boolean[] {true, false}) {
+                QueryUtils.INCLUDE_SENSITIVE = incl;
+
+                LogListener paramsLsnr = 
LogListener.matches(LONG_QUERY_FINISHED_MSG)
+                    .andMatches("params=[" + arg + "]").build();
+
+                LogListener finishedLsnr = 
LogListener.matches(LONG_QUERY_FINISHED_MSG).build();
+
+                log.registerListener(paramsLsnr);
+                log.registerListener(finishedLsnr);
+
+                cache.query(new SqlFieldsQuery("SELECT sleep(?)").setArgs(arg))

Review Comment:
   Use try-with-resources for cursor.



##########
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2QueryInfo.java:
##########
@@ -210,8 +224,12 @@ public synchronized void resumeTracking() {
                 .append(", enforceJoinOrder=").append(enforceJoinOrder)
                 .append(", schema=").append(schema)
                 .append(", initiatorId=").append(initiatorId)
-                .append(", sql='").append(sql)
-                .append("', plan=").append(plan());
+                .append(", sql='").append(sql).append("'");
+
+        if (QueryUtils.INCLUDE_SENSITIVE && params != null && params.length != 
0)

Review Comment:
   U can use `!F.isEmpty(params)`



##########
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2QueryInfo.java:
##########
@@ -76,6 +77,9 @@ public class H2QueryInfo implements TrackableQuery {
     /** Query initiator ID. */
     private final String initiatorId;
 
+    /** Query parameters. */
+    private final @Nullable Object[] params;

Review Comment:
   Can an array and its values ​​be null?



##########
modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/LongRunningQueryTest.java:
##########
@@ -546,6 +572,29 @@ private void checkInitiatorId(ListeningTestLogger log, 
String type, String sql,
         assertTrue(lsnr.check());
     }
 
+    /** */
+    private void checkParameters(
+        ListeningTestLogger log,
+        String type,
+        String sql,
+        boolean includeSensitive
+    ) throws InterruptedException {
+        int arg = LONG_QUERY_WARNING_TIMEOUT + LONG_QUERY_WARNING_TIMEOUT / 2;
+
+        LogListener paramsLsnr = 
LogListener.matches(LONG_QUERY_FINISHED_MSG).andMatches("type=" + type)
+            .andMatches("params=[" + arg + "]").build();
+
+        LogListener finishedLsnr = 
LogListener.matches(LONG_QUERY_FINISHED_MSG).andMatches("type=" + type).build();
+
+        log.registerListener(paramsLsnr);
+        log.registerListener(finishedLsnr);
+
+        ignite.cache("test").query(new 
SqlFieldsQuery(sql).setArgs(arg)).getAll();

Review Comment:
   Use try-with-resources for cursor.



-- 
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]

Reply via email to