1 33 package smallsql.database; 34 35 import java.sql.*; 36 37 public class TableStorePage extends StorePage{ 38 final Table table; 39 40 int lockType; 42 SSConnection con; 43 TableStorePage nextLock; 44 45 46 TableStorePage(SSConnection con, Table table, int lockType, long fileOffset){ 47 super( null, 0, table.raFile, fileOffset ); 48 this.con = con; 49 this.table = table; 50 this.lockType = lockType; 51 } 52 53 54 byte[] getData(){ 55 return page; 56 } 57 58 59 long commit() throws SQLException{ 61 if(nextLock != null){ 62 fileOffset = nextLock.commit(); 64 nextLock = null; 65 rollback(); 66 return fileOffset; 67 } 68 if(lockType == TableView.LOCK_READ) 69 return fileOffset; 70 return super.commit(); 71 } 72 73 74 final void freeLock(){ 75 table.freeLock(this); 76 } 77 } | Popular Tags |