You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Vladimir Ozerov (JIRA)" <ji...@apache.org> on 2018/03/19 08:20:00 UTC

[jira] [Updated] (IGNITE-5250) Unhelpful exception when value of wrong type is passed to H2

     [ https://issues.apache.org/jira/browse/IGNITE-5250?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vladimir Ozerov updated IGNITE-5250:
------------------------------------
    Issue Type: Bug  (was: Task)

> Unhelpful exception when value of wrong type is passed to H2
> ------------------------------------------------------------
>
>                 Key: IGNITE-5250
>                 URL: https://issues.apache.org/jira/browse/IGNITE-5250
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 2.0
>            Reporter: Denis Magda
>            Priority: Major
>              Labels: usability
>         Attachments: ExampleNodeStartup.java
>
>
> For instance, if an SQL schema defined this way:
> {code}
> cfg.setIndexedTypes(AffinityKey.class, Person.class);
> {code}
> and then, by some reason, the users confuses the type of the key passing {{int}} instead of {{AffinityKey}}
> {code}
>         SqlFieldsQuery query = new SqlFieldsQuery("INSERT INTO Person (_key, id, name, country ) " +
>             "VALUES ( ? , ? , ? , ?)");
>         // Setting the key of a wrong type (AffinityKey instance must be used instead).
>         query.setArgs(100, 1000, "John", "Canada");
>         // Getting not user friendly exception.
>         cache.query(query).getAll();
> {code}
> he will get an exception that doesn't point out to the exact root cause:
> {noformat}
> Caused by: class org.apache.ignite.IgniteException: Failed to execute SQL query.
> 	at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor$3.iterator(DmlStatementsProcessor.java:365)
> 	at org.apache.ignite.internal.processors.cache.QueryCursorImpl.iterator(QueryCursorImpl.java:94)
> 	at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.doInsert(DmlStatementsProcessor.java:836)
> 	at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.executeUpdateStatement(DmlStatementsProcessor.java:378)
> 	at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.updateSqlFields(DmlStatementsProcessor.java:173)
> 	at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.updateSqlFieldsTwoStep(DmlStatementsProcessor.java:207)
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryDistributedSqlFields(IgniteH2Indexing.java:1657)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor$5.applyx(GridQueryProcessor.java:1701)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor$5.applyx(GridQueryProcessor.java:1699)
> 	at org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2129)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor.querySqlFields(GridQueryProcessor.java:1706)
> 	at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:783)
> 	... 6 more
> Caused by: class org.apache.ignite.IgniteCheckedException: Failed to execute SQL query.
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.executeSqlQuery(IgniteH2Indexing.java:1224)
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.executeSqlQueryWithTimer(IgniteH2Indexing.java:1276)
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.access$1300(IgniteH2Indexing.java:239)
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$4.iterator(IgniteH2Indexing.java:1079)
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$4.iterator(IgniteH2Indexing.java:1067)
> 	at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor$3.iterator(DmlStatementsProcessor.java:362)
> 	... 18 more
> Caused by: org.h2.jdbc.JdbcSQLException: Hexadecimal string with odd number of characters: "100"; SQL statement:
> SELECT
> TABLE._KEY,
> TABLE.ID,
> TABLE.NAME,
> TABLE.COUNTRY
> FROM TABLE(_KEY OTHER=(?1,), ID BIGINT=(?2,), NAME VARCHAR=(?3,), COUNTRY VARCHAR=(?4,)) [90003-195]
> 	at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
> 	at org.h2.message.DbException.get(DbException.java:179)
> 	at org.h2.message.DbException.get(DbException.java:155)
> 	at org.h2.util.StringUtils.convertHexToBytes(StringUtils.java:930)
> 	at org.h2.value.Value.convertTo(Value.java:957)
> 	at org.h2.table.Column.convert(Column.java:167)
> 	at org.h2.expression.TableFunction.getTable(TableFunction.java:118)
> 	at org.h2.expression.TableFunction.getValue(TableFunction.java:41)
> 	at org.h2.table.FunctionTable.getValueResultSet(FunctionTable.java:218)
> 	at org.h2.table.FunctionTable.getResult(FunctionTable.java:189)
> 	at org.h2.index.FunctionIndex.find(FunctionIndex.java:50)
> 	at org.h2.index.BaseIndex.find(BaseIndex.java:128)
> 	at org.h2.index.IndexCursor.find(IndexCursor.java:169)
> 	at org.h2.table.TableFilter.next(TableFilter.java:468)
> 	at org.h2.command.dml.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1452)
> 	at org.h2.result.LazyResult.hasNext(LazyResult.java:79)
> 	at org.h2.result.LazyResult.next(LazyResult.java:59)
> 	at org.h2.command.dml.Select.queryFlat(Select.java:519)
> 	at org.h2.command.dml.Select.queryWithoutCache(Select.java:625)
> 	at org.h2.command.dml.Query.queryWithoutCacheLazyCheck(Query.java:114)
> 	at org.h2.command.dml.Query.query(Query.java:352)
> 	at org.h2.command.dml.Query.query(Query.java:333)
> 	at org.h2.command.CommandContainer.query(CommandContainer.java:113)
> 	at org.h2.command.Command.executeQuery(Command.java:201)
> 	at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:111)
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.executeSqlQuery(IgniteH2Indexing.java:1217)
> 	... 23 more
> {noformat}
> It makes sense to process the unclear exception like {{Caused by: org.h2.jdbc.JdbcSQLException: Hexadecimal string with odd number of characters: "100";}} internally and give user a hint how to fix it.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)