You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
H2 version 2.0.204 crashes when a database containing a view with a CTE is reopened for the second time. Reproducer:
user@test:~$ java -cp h2-2.0.204.jar org.h2.tools.Shell -url "jdbc:h2:~/tmp/h2test" -sql "CREATE OR REPLACE VIEW testview AS WITH subquery AS (SELECT 1 AS testcolumn) SELECT testcolumn FROM subquery;"
(Update count: 0, 129 ms)
user@test:~$ java -cp h2-2.0.204.jar org.h2.tools.Shell -url "jdbc:h2:~/tmp/h2test" -sql "SELECT * FROM testview"
TESTCOLUMN
1
(1 row, 16 ms)
user@test:~$ java -cp h2-2.0.204.jar org.h2.tools.Shell -url "jdbc:h2:~/tmp/h2test" -sql "SELECT * FROM testview"
Exception in thread "main" org.h2.jdbc.JdbcSQLSyntaxErrorException: View "SUBQUERY" already exists; SQL statement:
CREATE FORCE VIEW TABLE_EXPRESSION "PUBLIC"."SUBQUERY"("TESTCOLUMN") AS
SELECT
1 AS "TESTCOLUMN" [90038-204]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:651)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
at org.h2.message.DbException.get(DbException.java:227)
at org.h2.message.DbException.get(DbException.java:203)
at org.h2.command.ddl.CreateView.update(CreateView.java:90)
at org.h2.command.ddl.SchemaOwnerCommand.update(SchemaOwnerCommand.java:33)
at org.h2.engine.MetaRecord.prepareAndExecute(MetaRecord.java:77)
at org.h2.engine.Database.executeMeta(Database.java:660)
at org.h2.engine.Database.executeMeta(Database.java:634)
at org.h2.engine.Database.<init>(Database.java:357)
at org.h2.engine.Engine.openSession(Engine.java:92)
at org.h2.engine.Engine.openSession(Engine.java:222)
at org.h2.engine.Engine.createSession(Engine.java:201)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:117)
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:287)
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:270)
at org.h2.tools.Shell.runTool(Shell.java:148)
at org.h2.tools.Shell.main(Shell.java:82)
The text was updated successfully, but these errors were encountered:
Bisecting this issue leads to commit 74b1b25 ("populate meta with NEW objects even during startup"). After this commit, Database.addMeta() adds objects to the meta table also during the startup phase. However, Database.removeMeta()still does nothing during startup.
This means that the temporary cached table created by TableView.createShadowTableForRecursiveTableExpression() is never destroyed and clashes with the creation of the view when the database is reopened.
t-pa
added a commit
to t-pa/h2database
that referenced
this issue
Jan 25, 2022
H2 version 2.0.204 crashes when a database containing a view with a CTE is reopened for the second time. Reproducer:
The text was updated successfully, but these errors were encountered: