提交 ab3411b8 authored 作者: Thomas Mueller's avatar Thomas Mueller

Row not found when trying to delete for insert-delete-rollback.

上级 a4774af8
......@@ -452,18 +452,18 @@ public class Session extends SessionWithState {
logSystem.commit(this);
}
if (undoLog.size() > 0) {
if (database.isMultiVersion()) {
ArrayList<Row> rows = New.arrayList();
synchronized (database) {
while (undoLog.size() > 0) {
UndoLogRecord entry = undoLog.getLast();
entry.commit();
rows.add(entry.getRow());
undoLog.removeLast(false);
}
for (Row r : rows) {
r.commit();
}
// commit the rows, even when not using MVCC
// see also TableData.addRow
ArrayList<Row> rows = New.arrayList();
synchronized (database) {
while (undoLog.size() > 0) {
UndoLogRecord entry = undoLog.getLast();
entry.commit();
rows.add(entry.getRow());
undoLog.removeLast(false);
}
for (Row r : rows) {
r.commit();
}
}
undoLog.clear();
......
......@@ -114,9 +114,11 @@ public class TableData extends Table implements RecordReader {
public void addRow(Session session, Row row) throws SQLException {
int i = 0;
lastModificationId = database.getNextModificationDataId();
if (database.isMultiVersion()) {
row.setSessionId(session.getId());
}
// even when not using MVCC
// set the session, to ensure the row is kept in the cache
// until the transaction is committed or rolled back
// otherwise the row is not found when doing insert-delete-rollback
row.setSessionId(session.getId());
try {
for (; i < indexes.size(); i++) {
Index index = indexes.get(i);
......
......@@ -35,6 +35,7 @@ public class TestCases extends TestBase {
}
public void test() throws Exception {
testInsertDeleteRollback();
testLargeRollback();
testConstraintAlterTable();
testJoinWithView();
......@@ -72,6 +73,22 @@ public class TestCases extends TestBase {
deleteDb("cases");
}
private void testInsertDeleteRollback() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
stat.execute("set cache_size 1");
stat.execute("SET MAX_MEMORY_ROWS " + Integer.MAX_VALUE);
stat.execute("SET MAX_MEMORY_UNDO " + Integer.MAX_VALUE);
stat.execute("SET MAX_OPERATION_MEMORY " + Integer.MAX_VALUE);
stat.execute("create table test(id identity)");
conn.setAutoCommit(false);
stat.execute("insert into test select x from system_range(1, 11)");
stat.execute("delete from test");
conn.rollback();
conn.close();
}
private void testLargeRollback() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论