pavlukhin commented on a change in pull request #6490: IGNITE-7285 Add default 
query timeout
URL: https://github.com/apache/ignite/pull/6490#discussion_r329478355
 
 

 ##########
 File path: 
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java
 ##########
 @@ -134,6 +136,51 @@ public QueryParserResult parse(String schemaName, 
SqlFieldsQuery qry, boolean re
         return res;
     }
 
+    /**
+     * Create parameters from query.
+     *
+     * @param qry Query.
+     * @return Parameters.
+     */
+    public QueryParameters queryParameters(SqlFieldsQuery qry) {
+        NestedTxMode nestedTxMode = NestedTxMode.DEFAULT;
+        boolean autoCommit = true;
+        List<Object[]> batchedArgs = null;
+
+        if (qry instanceof SqlFieldsQueryEx) {
+            SqlFieldsQueryEx qry0 = (SqlFieldsQueryEx)qry;
+
+            if (qry0.getNestedTxMode() != null)
+                nestedTxMode = qry0.getNestedTxMode();
+
+            autoCommit = qry0.isAutoCommit();
+
+            batchedArgs = qry0.batchedArguments();
+        }
+
+        int timeout;
+
+        if (qry.getTimeout() >= 0) {
+            timeout = qry.getTimeout();
+        }
+        else {
+            timeout = 
(int)idx.kernalContext().config().getDefaultQueryTimeout();
+            A.ensure(timeout >= 0 && timeout <= Integer.MAX_VALUE, "timeout 
value should be valid Integer.");
 
 Review comment:
   It seems not valid place for validation. `timeout` has type `int` and will 
be definitely in `[0, Integer.MAX_VALUE]` range. I suggest to place validation 
inside a `IgniteConfiguration.setDefaultQueryTimeout` method.

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


With regards,
Apache Git Services

Reply via email to