Hi,

Yes, this is a bug. I will fix this for the next release. My patch is:

Index: src/main/org/h2/command/ddl/Analyze.java
===================================================================
--- src/main/org/h2/command/ddl/Analyze.java (revision 5932)
+++ src/main/org/h2/command/ddl/Analyze.java (working copy)
@@ -18,6 +18,7 @@
 import org.h2.util.StatementBuilder;
 import org.h2.value.Value;
 import org.h2.value.ValueInt;
+import org.h2.value.ValueNull;

 /**
  * This class represents the statement
@@ -91,7 +92,7 @@
             if (type == Value.BLOB || type == Value.CLOB) {
                 // can not index LOB columns, so calculating
                 // the selectivity is not required
-                buff.append("MAX(100)");
+                buff.append("MAX(NULL)");
             } else {

 buff.append("SELECTIVITY(").append(col.getSQL()).append(')');
             }
@@ -110,8 +111,11 @@
         ResultInterface result = command.query(0);
         result.next();
         for (int j = 0; j < columns.length; j++) {
-            int selectivity = result.currentRow()[j].getInt();
-            columns[j].setSelectivity(selectivity);
+            Value v = result.currentRow()[j];
+            if (v != ValueNull.INSTANCE) {
+                int selectivity = v.getInt();
+                columns[j].setSelectivity(selectivity);
+            }
         }
         if (manual) {
             db.updateMeta(session, table);


Regards,
Thomas


On Mon, Dec 1, 2014 at 3:08 PM, Michael Diamond <[email protected]
<javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote:

> Hi again, a similar bug report to
> https://groups.google.com/d/msg/h2-database/LaVe_shjeA8/xjxfgW-u2noJ from
> last year, I'm getting an exception while running many MERGE queries:
>
> org.h2.jdbc.JdbcSQLException: Literals of this kind are not allowed; SQL
> statement:
> SELECT SELECTIVITY(KEY), MAX(100) FROM PUBLIC.CACHE_HIST_DIVIDENDS LIMIT ?
> SAMPLE_SIZE ?  [90116-182]
>         at
> org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.message.DbException.get(DbException.java:179)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.message.DbException.get(DbException.java:155)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.message.DbException.get(DbException.java:144)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.checkLiterals(Parser.java:3319)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.read(Parser.java:3239)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.readIf(Parser.java:3105)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.readTerm(Parser.java:2718)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.readFactor(Parser.java:2251)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.readSum(Parser.java:2238)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.readConcat(Parser.java:2208)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.readCondition(Parser.java:2058)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.readAnd(Parser.java:2030)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.readExpression(Parser.java:2022)
> ~[h2-1.4.182.jar:1.4.182]
>         at
> org.h2.command.Parser.parseSelectSimpleSelectPart(Parser.java:1934)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.parseSelectSimple(Parser.java:1966)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.parseSelectSub(Parser.java:1860)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.parseSelectUnion(Parser.java:1681)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.parseSelect(Parser.java:1669)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.parsePrepared(Parser.java:433)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.parse(Parser.java:305)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.parse(Parser.java:277)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Parser.prepare(Parser.java:226)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.engine.Session.prepare(Session.java:412)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.engine.Session.prepare(Session.java:399)
> ~[h2-1.4.182.jar:1.4.182]
>         *at org.h2.command.ddl.Analyze.analyzeTable(Analyze.java:104)
> ~[h2-1.4.182.jar:1.4.182]*
>         at
> org.h2.table.RegularTable.analyzeIfRequired(RegularTable.java:433)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.table.RegularTable.addRow(RegularTable.java:152)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.dml.Merge.merge(Merge.java:161)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.dml.Merge.update(Merge.java:106)
> ~[h2-1.4.182.jar:1.4.182]
>         at
> org.h2.command.CommandContainer.update(CommandContainer.java:78)
> ~[h2-1.4.182.jar:1.4.182]
>         at org.h2.command.Command.executeUpdate(Command.java:254)
> ~[h2-1.4.182.jar:1.4.182]
>         at
> org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:157)
> ~[h2-1.4.182.jar:1.4.182]
>         at
> org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:143)
> ~[h2-1.4.182.jar:1.4.182]
>         at db.util.DBCache.put(DBCache.java:76) ~[bin/:?]
>         ... 5 more
>
> The problematic query looks to be in Analyze.java:104.  I haven't created
> a test case since it seems to be the same type of issue as my previous
> email, but I can try to put one together if needed.
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <javascript:_e(%7B%7D,'cvml','h2-database%[email protected]');>
> .
> To post to this group, send email to [email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>.
> Visit this group at http://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to