AMashenkov commented on a change in pull request #8821:
URL: https://github.com/apache/ignite/pull/8821#discussion_r581810888



##########
File path: 
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
##########
@@ -18,11 +18,35 @@
 package org.apache.ignite.internal.processors.query.h2.sql;
 
 import java.util.List;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
+
+import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_TO_STRING_INCLUDE_SENSITIVE;
+import static 
org.apache.ignite.internal.util.tostring.GridToStringBuilder.DFLT_TO_STRING_INCLUDE_SENSITIVE;
 
 /**
  * Base class for all SQL AST nodes.
  */
 public abstract class GridSqlElement implements GridSqlAst {
+    /** Setting to {@code true} enables writing sensitive information in 
{@code toString()} output. */
+    public static final boolean INCLUDE_SENSITIVE =
+        IgniteSystemProperties.getBoolean(IGNITE_TO_STRING_INCLUDE_SENSITIVE, 
DFLT_TO_STRING_INCLUDE_SENSITIVE);
+
+    /**
+     * Enables {@link 
IgniteSystemProperties#IGNITE_TO_STRING_INCLUDE_SENSITIVE} mode for current 
thread.
+     * Note, setting {@code INCL_SENS_TL} to {@code false} will lead to 
generation of invalid SQL query.
+     * For example:<br>
+     * source query - "SELECT * FROM TBL WHERE name = 'Name'"<br>
+     * generated query - "SELECT * FROM TBL WHERE name = ?" - there is no 
parameter value in query.<br>
+     * It's a desired behaviour, because, when {@link 
IgniteSystemProperties#IGNITE_TO_STRING_INCLUDE_SENSITIVE} {@code = false}
+     * we want to filter out all sensitive data and those data can be sitting 
in SQL constants.
+     *
+     * @see GridSqlConst#getSQL()
+     * @see IgniteH2Indexing#sqlWithoutConst(GridSqlStatement)
+     */
+    public static final ThreadLocal<Boolean> INCLUDE_SENSITIVE_TL =
+        ThreadLocal.withInitial(() -> DFLT_TO_STRING_INCLUDE_SENSITIVE);
+

Review comment:
       I don't like any logic \ thread locals in AST classes.
   Let's move this to e.g. QueryUtils class.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to