提交 64eef308 authored 作者: Thomas Mueller's avatar Thomas Mueller

MVCC: if the page store is disabled, rollback of multiple rows with the same…

MVCC: if the page store is disabled, rollback of multiple rows with the same index key did not work correctly.
上级 0f7df1d1
...@@ -122,6 +122,7 @@ public class UndoLogRecord { ...@@ -122,6 +122,7 @@ public class UndoLogRecord {
try { try {
if (!db.isPageStoreEnabled()) { if (!db.isPageStoreEnabled()) {
row.setKey(0); row.setKey(0);
row.setVersion(row.getVersion() - 1);
} }
table.addRow(session, row); table.addRow(session, row);
table.fireAfterRow(session, null, row, true); table.fireAfterRow(session, null, row, true);
......
...@@ -299,15 +299,9 @@ java org.h2.test.TestAll timer ...@@ -299,15 +299,9 @@ java org.h2.test.TestAll timer
/* /*
MVCCIndexCorruptedTest
power failure test: larger binaries and additional indexes power failure test: larger binaries and additional indexes
(with many columns). (with many columns).
instead of trigger on views
pseudo column rowid, oid, _rowid_
outer join bug outer join bug
// System.setProperty("h2.pageSize", "64"); // System.setProperty("h2.pageSize", "64");
......
...@@ -771,11 +771,11 @@ public abstract class TestBase { ...@@ -771,11 +771,11 @@ public abstract class TestBase {
/** /**
* Check that the result set row count matches. * Check that the result set row count matches.
* *
* @param rs the result set
* @param expected the number of expected rows * @param expected the number of expected rows
* @param rs the result set
* @throws AssertionError if a different number of rows have been found * @throws AssertionError if a different number of rows have been found
*/ */
protected void assertResultRowCount(ResultSet rs, int expected) throws SQLException { protected void assertResultRowCount(int expected, ResultSet rs) throws SQLException {
int i = 0; int i = 0;
while (rs.next()) { while (rs.next()) {
i++; i++;
......
...@@ -106,16 +106,16 @@ public class TestTempTables extends TestBase { ...@@ -106,16 +106,16 @@ public class TestTempTables extends TestBase {
s1.execute("create local temporary table test_temp(id int) on commit delete rows"); s1.execute("create local temporary table test_temp(id int) on commit delete rows");
s1.execute("insert into test_temp values(1)"); s1.execute("insert into test_temp values(1)");
rs = s1.executeQuery("select * from test_temp"); rs = s1.executeQuery("select * from test_temp");
assertResultRowCount(rs, 1); assertResultRowCount(1, rs);
c1.commit(); c1.commit();
rs = s1.executeQuery("select * from test_temp"); rs = s1.executeQuery("select * from test_temp");
assertResultRowCount(rs, 0); assertResultRowCount(0, rs);
s1.execute("drop table test_temp"); s1.execute("drop table test_temp");
s1.execute("create local temporary table test_temp(id int) on commit drop"); s1.execute("create local temporary table test_temp(id int) on commit drop");
s1.execute("insert into test_temp values(1)"); s1.execute("insert into test_temp values(1)");
rs = s1.executeQuery("select * from test_temp"); rs = s1.executeQuery("select * from test_temp");
assertResultRowCount(rs, 1); assertResultRowCount(1, rs);
c1.commit(); c1.commit();
try { try {
s1.executeQuery("select * from test_temp"); s1.executeQuery("select * from test_temp");
......
...@@ -34,6 +34,7 @@ public class TestTransaction extends TestBase { ...@@ -34,6 +34,7 @@ public class TestTransaction extends TestBase {
} }
public void test() throws SQLException { public void test() throws SQLException {
testRollback();
testSetTransaction(); testSetTransaction();
testReferential(); testReferential();
testSavepoint(); testSavepoint();
...@@ -41,6 +42,51 @@ public class TestTransaction extends TestBase { ...@@ -41,6 +42,51 @@ public class TestTransaction extends TestBase {
deleteDb("transaction"); deleteDb("transaction");
} }
private void testRollback() throws SQLException {
deleteDb("transaction");
Connection conn = getConnection("transaction");
Statement stat = conn.createStatement();
stat.execute("create table test(id int)");
stat.execute("create index idx_id on test(id)");
stat.execute("insert into test values(1), (1)");
if (!config.memory) {
conn.close();
conn = getConnection("transaction");
stat = conn.createStatement();
}
conn.setAutoCommit(false);
stat.execute("delete from test");
conn.rollback();
ResultSet rs;
rs = stat.executeQuery("select * from test where id = 1");
assertResultRowCount(2, rs);
conn.close();
conn = getConnection("transaction");
stat = conn.createStatement();
stat.execute("create table master(id int) as select 1");
stat.execute("create table child1(id int references master(id) on delete cascade)");
stat.execute("insert into child1 values(1), (1)");
stat.execute("create table child2(id int references master(id)) as select 1");
if (!config.memory) {
conn.close();
conn = getConnection("transaction");
stat = conn.createStatement();
}
stat = conn.createStatement();
try {
stat.execute("delete from master");
fail();
} catch (SQLException ex) {
// ok
}
rs = stat.executeQuery("select * from master where id=1");
assertResultRowCount(1, rs);
rs = stat.executeQuery("select * from child1 where id=1");
assertResultRowCount(2, rs);
conn.close();
}
private void testSetTransaction() throws SQLException { private void testSetTransaction() throws SQLException {
deleteDb("transaction"); deleteDb("transaction");
Connection conn = getConnection("transaction"); Connection conn = getConnection("transaction");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论