1 5 package org.h2.store; 6 7 import java.sql.SQLException ; 8 9 import org.h2.message.Message; 10 11 public class InDoubtTransaction { 12 13 public static final int IN_DOUBT = 0, COMMIT = 1, ROLLBACK = 2; 14 15 17 private LogFile log; 18 private int sessionId; 19 private int pos; 20 private String transaction; 21 private int blocks; 22 private int state; 23 24 public InDoubtTransaction(LogFile log, int sessionId, int pos, String transaction, int blocks) { 25 this.log = log; 26 this.sessionId = sessionId; 27 this.pos = pos; 28 this.transaction = transaction; 29 this.blocks = blocks; 30 this.state = IN_DOUBT; 31 } 32 33 public void setState(int state) throws SQLException { 34 switch(state) { 35 case COMMIT: 36 log.updatePreparedCommit(true, pos, sessionId, blocks); 37 break; 38 case ROLLBACK: 39 log.updatePreparedCommit(false, pos, sessionId, blocks); 40 break; 41 default: 42 throw Message.getInternalError("state="+state); 43 } 44 this.state = state; 45 } 46 47 public String getState() { 48 switch(state) { 49 case IN_DOUBT: 50 return "IN_DOUBT"; 51 case COMMIT: 52 return "COMMIT"; 53 case ROLLBACK: 54 return "ROLLBACK"; 55 default: 56 throw Message.getInternalError("state="+state); 57 } 58 } 59 60 public int getPos() { 61 return pos; 62 } 63 64 public int getSessionId() { 65 return sessionId; 66 } 67 68 public String getTransaction() { 69 return transaction; 70 } 71 72 } 73 | Popular Tags |