ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [27/50] [abbrv] incubator-ignite git commit: #ignite-947: Validate number of query arguments.
Date Mon, 01 Jun 2015 02:44:34 GMT
#ignite-947: Validate number of query arguments.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c7838866
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c7838866
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c7838866

Branch: refs/heads/ignite-868
Commit: c7838866b3cf678e8d7dce826f3dec831ced7802
Parents: 70429eb
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Thu May 28 13:10:15 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Thu May 28 13:10:15 2015 +0300

----------------------------------------------------------------------
 .../query/h2/sql/GridSqlQuerySplitter.java          |  4 ++++
 .../query/h2/sql/BaseH2CompareQueryTest.java        | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c7838866/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
index 6c7e2e2..b1d8913 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
@@ -288,6 +288,10 @@ public class GridSqlQuerySplitter {
             while (target.size() < idx)
                 target.add(null);
 
+            if (params.length <= idx)
+                throw new IgniteException("Invalid number of query parameters. " +
+                    "Cannot find " + idx + " parameter.");
+
             Object param = params[idx];
 
             if (idx == target.size())

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c7838866/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
index 7cdf0bc..99366f0 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.query.h2.sql;
 
+import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.*;
 import org.apache.ignite.cache.query.*;
@@ -180,6 +181,21 @@ public class BaseH2CompareQueryTest extends AbstractH2CompareQueryTest
{
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testInvalidQuery() throws Exception {
+        final SqlFieldsQuery sql = new SqlFieldsQuery("SELECT firstName from Person where
id <> ? and orgId <> ?");
+
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                pCache.query(sql.setArgs(3));
+
+                return null;
+            }
+        }, IgniteException.class, "Invalid number of query parameters.");
+    }
+
+    /**
      * @throws Exception
      */
     // TODO: IGNITE-705


Mime
View raw message