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
95 TrieUndoLogInfo() { bucketPtr_
= NULL
; }
98 class DllExport Transaction
103 IsolationLevel isoLevel_
;
105 TransHasNode
*hasLockList_
;
107 UndoLogInfo
*firstUndoLog_
;
109 LockHashNode
*waitLock_
;
111 DbRetVal
releaseAllLocks(LockManager
*lockManager_
);
113 void updateWaitLock(LockHashNode
*node
) { waitLock_
= node
; }
114 void removeWaitLock() { waitLock_
= NULL
; }
115 DbRetVal
insertIntoHasList(Database
*sysdb
, LockHashNode
*node
);
116 DbRetVal
removeFromHasList(Database
*sysdb
, void *tuple
);
117 bool findInHasList(Database
*sysdb
, LockHashNode
*node
);
119 DbRetVal
appendUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
);
120 DbRetVal
appendLogicalUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
, void *indexPtr
);
121 DbRetVal
appendLogicalHashUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
);
122 DbRetVal
appendLogicalTreeUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
);
123 DbRetVal
appendLogicalTrieUndoLog(Database
*sysdb
, OperationType type
, void *data
, size_t size
);
124 UndoLogInfo
* createUndoLog(Database
*sysdb
, OperationType type
, void *data
,
125 size_t size
, DbRetVal
*rv
);
126 void addAtBegin(UndoLogInfo
* logInfo
);
128 UndoLogInfo
* popUndoLog();
129 DbRetVal
removeUndoLogs(Database
*sysdb
);
130 DbRetVal
applyUndoLogs(Database
*sysdb
);
132 void printDebugInfo(Database
*sysdb
);
133 void printTotalNodes();
136 DbRetVal
handleVarcharUndoInsert(Database
*sysdb
, char *data
);
137 DbRetVal
handleVarcharUndoDelete(Database
*sysdb
, char *data
);
138 DbRetVal
handleVarcharUndoUpdate(Database
*sysdb
, char *data
,void *ptrToTuple
);
141 class DllExport TransactionManager
144 TransactionManager() { }
145 ~TransactionManager() {}
146 //Transaction *trans;
148 Transaction
*firstTrans
;
149 IsolationLevel
getIsoLevel() {
150 if(firstTrans
) return firstTrans
->isoLevel_
;
151 else return READ_COMMITTED
;}
152 void setFirstTrans(Transaction
*trans
);
153 void printUsageStatistics();
154 void printDebugInfo(Database
*sysdb
);
156 DbRetVal
startTransaction(LockManager
*lManager
, IsolationLevel level
);
157 DbRetVal
commit(LockManager
*lManager
);
158 DbRetVal
rollback(LockManager
*lManager
, Transaction
*t
=NULL
);
159 bool isTransactionConsistent(Database
*db
);