1 package com.quadcap.sql; 2 3 40 41 import java.io.Externalizable ; 42 import java.io.IOException ; 43 import java.io.ObjectInput ; 44 import java.io.ObjectOutput ; 45 46 import java.util.Vector ; 47 48 import java.sql.SQLException ; 49 50 import com.quadcap.sql.file.Datafile; 51 import com.quadcap.sql.file.DatafileException; 52 import com.quadcap.sql.file.LogEntry; 53 54 import com.quadcap.sql.lock.Transaction; 55 56 import com.quadcap.util.Debug; 57 58 63 public abstract class LogStep extends LogEntry { 64 Session mySession; 65 66 public LogStep() { 67 super(-1, -1, STEP); 68 } 69 70 public LogStep(Session session) { 71 super(session.getTransactionId(), session.getStmtId(), STEP); 72 mySession = session; 73 } 74 75 78 public void undo(Transaction t, Datafile df) 79 throws IOException , DatafileException 80 { 81 try { 82 Session s = mySession; 83 if (s == null) { 84 Database db = (Database)df; 85 s = db.getSession(t); 86 } 87 undo(s); 88 if (Trace.bit(15)) { 90 Debug.println("LogStep.UNDO(" + this + ")"); 91 } 92 } catch (SQLException ex) { 94 throw new DatafileException(ex); 95 } 96 } 97 98 101 public void redo(Transaction t, Datafile df) 102 throws IOException , DatafileException 103 { 104 try { 105 Session s = mySession; 106 if (s == null) { 107 Database db = (Database)df; 108 s = db.getSession(t); 109 } 110 redo(s); 111 if (Trace.bit(16)) { 113 Debug.println("LogStep.redo(" + this + ")"); 114 } 115 } catch (SQLException ex) { 117 throw new DatafileException(ex); 118 } 119 } 120 121 124 abstract public void undo(Session session) 125 throws IOException , SQLException 126 ; 127 128 131 abstract public void redo(Session session) 132 throws IOException , SQLException 133 ; 134 135 141 public void prepare(Session session) throws IOException , SQLException { 142 mySession = session; 143 } 144 } 145 | Popular Tags |