From eb9193b1f49bc96efaeebc932527f7f9a1242b3d Mon Sep 17 00:00:00 2001 From: Martin Vahlensieck Date: Thu, 19 Dec 2024 16:27:24 +0100 Subject: [PATCH] Add test for rollback behavior of catalogs with materialized views --- .../sql/view/BasicMaterializedViewTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/dbms/src/test/java/org/polypheny/db/sql/view/BasicMaterializedViewTest.java b/dbms/src/test/java/org/polypheny/db/sql/view/BasicMaterializedViewTest.java index f91797db74..2bd09c91e1 100644 --- a/dbms/src/test/java/org/polypheny/db/sql/view/BasicMaterializedViewTest.java +++ b/dbms/src/test/java/org/polypheny/db/sql/view/BasicMaterializedViewTest.java @@ -1312,4 +1312,31 @@ public void testMaterializedViewFromView() throws SQLException { } } + + @Test + public void testMaterializedViewRollback() throws SQLException { + try ( JdbcConnection polyphenyDbConnection = new JdbcConnection( false ) ) { + Connection connection = polyphenyDbConnection.getConnection(); + try ( Statement statement = connection.createStatement() ) { + statement.executeUpdate( VIEW_TEST_EMP_TABLE_SQL ); + + try { + statement.executeUpdate( "CREATE MATERIALIZED VIEW viewTestEmp AS SELECT * FROM viewTestEmpTable" ); + statement.executeUpdate( "CREATE MATERIALIZED VIEW viewTestEmp1 AS SELECT * FROM viewTestEmpTable" ); + statement.executeUpdate( VIEW_TEST_EMP_TABLE_DATA_SQL ); + + // Force a rollback of the catalog + connection.rollback(); + + // Drop the materialized views + statement.executeUpdate( "DROP MATERIALIZED VIEW viewTestEmp" ); + statement.executeUpdate( "DROP MATERIALIZED VIEW viewTestEmp1" ); + } finally { + statement.executeUpdate( "DROP TABLE viewTestEmpTable" ); + dropTables( statement ); + } + } + } + } + }