Unverified 提交 9e734920 authored 作者: Andrei Tokar's avatar Andrei Tokar 提交者: GitHub

Merge pull request #1179 from h2database/drop-readlogid

Drop TransactionMap.readLogId
......@@ -380,7 +380,7 @@ public class MVPrimaryIndex extends BaseIndex {
return dataMap;
}
Transaction t = session.getTransaction();
return dataMap.getInstance(t, Long.MAX_VALUE);
return dataMap.getInstance(t);
}
/**
......
......@@ -463,7 +463,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
return dataMap;
}
Transaction t = session.getTransaction();
return dataMap.getInstance(t, Long.MAX_VALUE);
return dataMap.getInstance(t);
}
/**
......
......@@ -328,7 +328,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
return dataMap;
}
Transaction t = session.getTransaction();
return dataMap.getInstance(t, Long.MAX_VALUE);
return dataMap.getInstance(t);
}
/**
......
......@@ -55,7 +55,6 @@ public class TestTransactionStore extends TestBase {
testStopWhileCommitting();
testGetModifiedMaps();
testKeyIterator();
testMultiStatement();
testTwoPhaseCommit();
testSavepoint();
testConcurrentTransactionsReadCommitted();
......@@ -537,96 +536,6 @@ public class TestTransactionStore extends TestBase {
s.close();
}
/**
* Tests behavior when used for a sequence of SQL statements. Each statement
* uses a savepoint. Within a statement, changes by the statement itself are
* not seen; the change is only seen when the statement finished.
* <p>
* Update statements that change the key of multiple rows may use delete/add
* pairs to do so (they don't need to first delete all entries and then
* re-add them). Trying to add multiple values for the same key is not
* allowed (an update statement that would result in a duplicate key).
*/
private void testMultiStatement() {
MVStore s = MVStore.open(null);
TransactionStore ts = new TransactionStore(s);
ts.init();
Transaction tx;
TransactionMap<String, String> m;
long startUpdate;
tx = ts.begin();
// start of statement
// create table test
startUpdate = tx.setSavepoint();
m = tx.openMap("test");
m.setSavepoint(startUpdate);
// start of statement
// insert into test(id, name) values(1, 'Hello'), (2, 'World')
startUpdate = tx.setSavepoint();
m.setSavepoint(startUpdate);
assertTrue(m.trySet("1", "Hello", true));
assertTrue(m.trySet("2", "World", true));
// not seen yet (within the same statement)
assertNull(m.get("1"));
assertNull(m.get("2"));
// start of statement
startUpdate = tx.setSavepoint();
// now we see the newest version
m.setSavepoint(startUpdate);
assertEquals("Hello", m.get("1"));
assertEquals("World", m.get("2"));
// update test set primaryKey = primaryKey + 1
// (this is usually a tricky case)
assertEquals("Hello", m.get("1"));
assertTrue(m.trySet("1", null, true));
assertTrue(m.trySet("2", "Hello", true));
assertEquals("World", m.get("2"));
// already updated by this statement, so it has no effect
// but still returns true because it was changed by this transaction
assertTrue(m.trySet("2", null, true));
assertTrue(m.trySet("3", "World", true));
// not seen within this statement
assertEquals("Hello", m.get("1"));
assertEquals("World", m.get("2"));
assertNull(m.get("3"));
// start of statement
startUpdate = tx.setSavepoint();
m.setSavepoint(startUpdate);
// select * from test
assertNull(m.get("1"));
assertEquals("Hello", m.get("2"));
assertEquals("World", m.get("3"));
// start of statement
startUpdate = tx.setSavepoint();
m.setSavepoint(startUpdate);
// update test set id = 1
// should fail: duplicate key
assertTrue(m.trySet("2", null, true));
assertTrue(m.trySet("1", "Hello", true));
assertTrue(m.trySet("3", null, true));
assertFalse(m.trySet("1", "World", true));
tx.rollbackToSavepoint(startUpdate);
startUpdate = tx.setSavepoint();
m.setSavepoint(startUpdate);
assertNull(m.get("1"));
assertEquals("Hello", m.get("2"));
assertEquals("World", m.get("3"));
tx.commit();
ts.close();
s.close();
}
private void testTwoPhaseCommit() {
String fileName = getBaseDir() + "/testTwoPhaseCommit.h3";
FileUtils.delete(fileName);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论