ignite-1142 - fixes for parameter type substitution
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/cfd1fb27 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/cfd1fb27 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/cfd1fb27 Branch: refs/heads/ignite-1142 Commit: cfd1fb27f6614a93f8de3021066900b2c865d0bc Parents: 06d03e8 Author: S.Vladykin <svlady...@gridgain.com> Authored: Thu Jul 30 23:48:25 2015 +0300 Committer: S.Vladykin <svlady...@gridgain.com> Committed: Thu Jul 30 23:48:25 2015 +0300 ---------------------------------------------------------------------- .../processors/query/h2/IgniteH2Indexing.java | 14 ++++++++++++-- .../processors/query/h2/sql/GridSqlQuerySplitter.java | 7 +++++-- 2 files changed, 17 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cfd1fb27/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java index c76dbe7..df6ac49 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java @@ -599,6 +599,9 @@ public class IgniteH2Indexing implements GridQueryIndexing { String name = rsMeta.getColumnLabel(i); String type = rsMeta.getColumnClassName(i); + if (type == null) // Expression always returns NULL. + type = Void.class.getName(); + meta.add(new SqlFieldMetadata(schemaName, typeName, name, type)); } @@ -852,6 +855,14 @@ public class IgniteH2Indexing implements GridQueryIndexing { throw new CacheException("Failed to parse query: " + sqlQry, e); } + try { + bindParameters(stmt, F.asList(qry.getArgs())); + } + catch (IgniteCheckedException e) { + throw new CacheException("Failed to bind parameters: [qry=" + sqlQry + ", params=" + + Arrays.deepToString(qry.getArgs()) + "]", e); + } + GridCacheTwoStepQuery twoStepQry; List<GridQueryFieldMetadata> meta; @@ -1881,8 +1892,7 @@ public class IgniteH2Indexing implements GridQueryIndexing { * @param type Type. */ SqlFieldMetadata(@Nullable String schemaName, @Nullable String typeName, String name, String type) { - assert name != null; - assert type != null; + assert name != null && type != null : schemaName + " | " + typeName + " | " + name + " | " + type; this.schemaName = schemaName; this.typeName = typeName; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cfd1fb27/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 fe53101..9326b01 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 @@ -241,8 +241,11 @@ public class GridSqlQuerySplitter { GridSqlElement col = cols.get(i); GridSqlType t = col.resultType(); - if (t == null || t == GridSqlType.UNKNOWN) - throw new IllegalStateException("Type: " + t + " -> " + col); + if (t == null) + throw new NullPointerException("Column type."); + + if (t == GridSqlType.UNKNOWN) + throw new IllegalStateException("Unknown type: " + col); String alias;