NPE after upgrade from H2 4.1.197 to any later version

79 views
Skip to first unread message

Christopher Deckers

unread,
Nov 22, 2019, 5:14:54 AM11/22/19
to h2-da...@googlegroups.com
Hi all,

I just upgraded H2 from 1.4.197 to 1.4.200 and we are now hitting a NPE. I narrowed down the case and it seems to be related to executing multiple statements in 1, with a specific sequence. Out of curiosity I tried 1.4.198 and 1.4.199 and the bug also occurs there.

The statement (to be executed in a single statement):
CREATE TABLE TblA (AField DOUBLE);
CREATE INDEX TblAIndex ON TblA(AField);
ALTER TABLE TblA ADD (PrevDate DOUBLE);
CREATE TABLE TblB(AField DOUBLE) AS SELECT AField FROM TblA;

The NPE (MV_STORE FALSE):
Caused by: java.lang.NullPointerException
at com.h2database/org.h2.pagestore.db.PageStoreTable.getRowCountApproximation(PageStoreTable.java:510)
at com.h2database/org.h2.pagestore.db.ScanIndex.getCost(ScanIndex.java:122)
at com.h2database/org.h2.table.TableFilter.getBestPlanItem(TableFilter.java:234)
at com.h2database/org.h2.table.Plan.calculateCost(Plan.java:120)
at com.h2database/org.h2.command.dml.Optimizer.testPlan(Optimizer.java:181)

The NPE (MV_STORE TRUE):
Caused by: java.lang.NullPointerException
at com.h2database/org.h2.mvstore.db.MVTable.lock(MVTable.java:132)
at com.h2database/org.h2.table.TableFilter.lock(TableFilter.java:207)
at com.h2database/org.h2.command.dml.Select.queryWithoutCache(Select.java:819)
at com.h2database/org.h2.command.dml.Query.queryWithoutCacheLazyCheck(Query.java:201)
at com.h2database/org.h2.command.dml.Query.query(Query.java:489)
at com.h2database/org.h2.command.dml.Insert.insertRows(Insert.java:217)
at com.h2database/org.h2.command.dml.Insert.update(Insert.java:151)
at com.h2database/org.h2.command.ddl.CreateTable.update(CreateTable.java:145)

Are we doing something wrong?

I add our minimal test case as an attachment, you can simply run it. You can also easily switch between the 2 stores too.

Thanks a lot for the amazing work!
-Christopher

H2NpeTest.java

Andrei Tokar

unread,
Dec 15, 2019, 9:24:52 PM12/15/19
to H2 Database
I can not reproduce it with current master branch (but easily in 1.4.200). Got to be fixed by now.
Reply all
Reply to author
Forward
0 new messages