Skip to content

Commit

Permalink
fix for rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo committed Oct 11, 2024
1 parent 970883a commit acaa315
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,14 @@ public synchronized void commit() {


public void rollback() {
long id = snapshot.id();

commitActions.clear();
commitConstraints.clear();

restoreLastState();

log.debug( "rollback" );

if ( id != snapshot.id() ) {
updateSnapshot();
}

updateSnapshot();
}


Expand Down
47 changes: 47 additions & 0 deletions dbms/src/test/java/org/polypheny/db/catalog/RollbackTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2019-2024 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.polypheny.db.catalog;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.polypheny.db.TestHelper;

@SuppressWarnings("SqlNoDataSourceInspection")
public class RollbackTest {

@BeforeAll
public static void setUp() {
//noinspection ResultOfMethodCallIgnored
TestHelper.getInstance();
}

@Test
public void failedCreateRollbackTest() {
Assertions.assertThrows( Exception.class, () -> {
TestHelper.executeSql(
( c, s ) -> s.executeUpdate( "CREATE TABLE t (a BOOLEAN)" )
);
} );

TestHelper.executeSql(
( c, s ) -> s.executeUpdate( "DROP TABLE IF EXISTS t" )
);

}

}

0 comments on commit acaa315

Please sign in to comment.