1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 ***************************************************************************/
41 InsertHashIndexOperation
= 3,
42 UpdateHashIndexOperation
= 4,
43 DeleteHashIndexOperation
= 5,
44 InsertTreeIndexOperation
= 6,
45 UpdateTreeIndexOperation
= 7,
46 DeleteTreeIndexOperation
= 8
52 OperationType opType_
;
56 printf("<UndoLogInfo>\n");
57 printf(" <Size> %d </Size>\n", size_
);
58 printf(" <OperationType> %d </OperationType>\n", opType_
);
59 printf(" <TuplePtr> %x </TuplePtr>\n", (void *) *(long *)data_
);
60 printf("</UndoLogInfo>\n");
74 { metaData_
= tuple_
= keyPtr_
= hChunk_
= bucket_
= NULL
; }
83 void *cIndex_
;//CINDEX ptr
85 { metaData_
= tuple_
= cIndex_
= NULL
; }
88 class DllExport Transaction
93 IsolationLevel isoLevel_
;
95 TransHasNode
*hasLockList_
;
97 UndoLogInfo
*firstUndoLog_
;
99 LockHashNode
*waitLock_
;
101 DbRetVal
releaseAllLocks(LockManager
*lockManager_
);
103 void updateWaitLock(LockHashNode
*node
) { waitLock_
= node
; }
104 void removeWaitLock() { waitLock_
= NULL
; }
105 DbRetVal
insertIntoHasList(Database
*sysdb
, LockHashNode
*node
);
106 DbRetVal
removeFromHasList(Database
*sysdb
, void *tuple
);
107 bool findInHasList(Database
*sysdb
, LockHashNode
*node
);
109 DbRetVal
appendUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
);
110 DbRetVal
appendLogicalUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
, void *indexPtr
);
111 DbRetVal
appendLogicalHashUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
);
112 DbRetVal
appendLogicalTreeUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
);
113 UndoLogInfo
* createUndoLog(Database
*sysdb
, OperationType type
, void *data
,
114 size_t size
, DbRetVal
*rv
);
115 void addAtBegin(UndoLogInfo
* logInfo
);
117 UndoLogInfo
* popUndoLog();
118 DbRetVal
removeUndoLogs(Database
*sysdb
);
119 DbRetVal
applyUndoLogs(Database
*sysdb
);
121 void printDebugInfo(Database
*sysdb
);
124 DbRetVal
handleVarcharUndoInsert(Database
*sysdb
, char *data
);
125 DbRetVal
handleVarcharUndoDelete(Database
*sysdb
, char *data
);
126 DbRetVal
handleVarcharUndoUpdate(Database
*sysdb
, char *data
,void *ptrToTuple
);
129 class DllExport TransactionManager
132 TransactionManager() { }
133 ~TransactionManager() {}
134 //Transaction *trans;
136 Transaction
*firstTrans
;
137 IsolationLevel
getIsoLevel() {
138 if(firstTrans
) return firstTrans
->isoLevel_
;
139 else return READ_COMMITTED
;}
140 void setFirstTrans(Transaction
*trans
);
141 void printUsageStatistics();
142 void printDebugInfo(Database
*sysdb
);
144 DbRetVal
startTransaction(LockManager
*lManager
, IsolationLevel level
);
145 DbRetVal
commit(LockManager
*lManager
);
146 DbRetVal
rollback(LockManager
*lManager
, Transaction
*t
=NULL
);
147 bool isTransactionConsistent(Database
*db
);