Debian Codegraph @

src/main/org/h2/mvstore/db/MVInDoubtTransaction.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.mvstore.db;
7
8 import org.h2.mvstore.MVStore;
9 import org.h2.mvstore.tx.Transaction;
10 import org.h2.store.InDoubtTransaction;
11
12 /**
13 * An in-doubt transaction.
14 */
15 final class MVInDoubtTransaction implements InDoubtTransaction {
16
17 private final MVStore store;
18 private final Transaction transaction;
19 private int state = InDoubtTransaction.IN_DOUBT;
20
21 MVInDoubtTransaction(MVStore store, Transaction transaction) {
22 this.store = store;
23 this.transaction = transaction;
24 }
25
26 @Override
27 public void setState(int state) {
28 if (state == InDoubtTransaction.COMMIT) {
29 transaction.commit();
30 } else {
31 transaction.rollback();
32 }
33 store.commit();
34 this.state = state;
35 }
36
37 @Override
38 public int getState() {
39 return state;
40 }
41
42 @Override
43 public String getTransactionName() {
44 return transaction.getName();
45 }
46
47 }