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,
47 InsertTrieIndexOperation
= 9,
48 UpdateTrieIndexOperation
= 10,
49 DeleteTrieIndexOperation
= 11
55 OperationType opType_
;
59 printf("<UndoLogInfo>\n");
60 printf(" <Size> %d </Size>\n", size_
);
61 printf(" <OperationType> %d </OperationType>\n", opType_
);
62 printf(" <TuplePtr> %x </TuplePtr>\n", (void *) *(long *)data_
);
63 printf("</UndoLogInfo>\n");
77 { metaData_
= tuple_
= keyPtr_
= hChunk_
= bucket_
= NULL
; }
86 void *cIndex_
;//CINDEX ptr
88 { metaData_
= tuple_
= cIndex_
= NULL
; }
90 class TrieUndoLogInfo
:public HashUndoLogInfo
94 class DllExport Transaction
99 IsolationLevel isoLevel_
;
101 TransHasNode
*hasLockList_
;
103 UndoLogInfo
*firstUndoLog_
;
105 LockHashNode
*waitLock_
;
107 DbRetVal
releaseAllLocks(LockManager
*lockManager_
);
109 void updateWaitLock(LockHashNode
*node
) { waitLock_
= node
; }
110 void removeWaitLock() { waitLock_
= NULL
; }
111 DbRetVal
insertIntoHasList(Database
*sysdb
, LockHashNode
*node
);
112 DbRetVal
removeFromHasList(Database
*sysdb
, void *tuple
);
113 bool findInHasList(Database
*sysdb
, LockHashNode
*node
);
115 DbRetVal
appendUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
);
116 DbRetVal
appendLogicalUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
, void *indexPtr
);
117 DbRetVal
appendLogicalHashUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
);
118 DbRetVal
appendLogicalTreeUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
);
119 DbRetVal
appendLogicalTrieUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
);
120 UndoLogInfo
* createUndoLog(Database
*sysdb
, OperationType type
, void *data
,
121 size_t size
, DbRetVal
*rv
);
122 void addAtBegin(UndoLogInfo
* logInfo
);
124 UndoLogInfo
* popUndoLog();
125 DbRetVal
removeUndoLogs(Database
*sysdb
);
126 DbRetVal
applyUndoLogs(Database
*sysdb
);
128 void printDebugInfo(Database
*sysdb
);
129 void printTotalNodes();
132 DbRetVal
handleVarcharUndoInsert(Database
*sysdb
, char *data
);
133 DbRetVal
handleVarcharUndoDelete(Database
*sysdb
, char *data
);
134 DbRetVal
handleVarcharUndoUpdate(Database
*sysdb
, char *data
,void *ptrToTuple
);
137 class DllExport TransactionManager
140 TransactionManager() { }
141 ~TransactionManager() {}
142 //Transaction *trans;
144 Transaction
*firstTrans
;
145 IsolationLevel
getIsoLevel() {
146 if(firstTrans
) return firstTrans
->isoLevel_
;
147 else return READ_COMMITTED
;}
148 void setFirstTrans(Transaction
*trans
);
149 void printUsageStatistics();
150 void printDebugInfo(Database
*sysdb
);
152 DbRetVal
startTransaction(LockManager
*lManager
, IsolationLevel level
);
153 DbRetVal
commit(LockManager
*lManager
);
154 DbRetVal
rollback(LockManager
*lManager
, Transaction
*t
=NULL
);
155 bool isTransactionConsistent(Database
*db
);