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 ***************************************************************************/
20 #include<Transaction.h>
23 #include<CatalogTables.h>
26 #include<DatabaseManagerImpl.h>
49 TupleIterator(Predicate
*p
, ScanType t
, IndexInfo
*i
, void *cptr
)
50 { pred_
= p
; scanType_
= t
; info
= i
; chunkPtr_
= cptr
; }
56 class TableImpl
:public Table
63 //This is pointer to the pointer stored in the
64 //Transaction manager.
65 //If the transaction commits/aborts this pointer changes
66 //and this will get that newly allocated transaction
68 char tblName_
[IDENTIFIER_LENGTH
];
70 size_t length_
; //length of the tuple
77 //ChunkIterator *iter;
85 int useIndex_
;//offet in the above array indexPtr_ for scan
92 //copy Values from binded buffer to tuple pointed by arg
93 DbRetVal
copyValuesFromBindBuffer(void *tuple
);
94 DbRetVal
copyValuesToBindBuffer(void *tuple
);
96 DbRetVal
insertIndexNode(Transaction
*trans
, void *indexPtr
, void *tuple
);
97 DbRetVal
updateIndexNode(Transaction
*trans
, void *indexPtr
, void *tuple
);
98 DbRetVal
deleteIndexNode(Transaction
*trans
, void *indexPtr
, void *tuple
);
100 DbRetVal
createPlan();
101 Chunk
* getSystemTableChunk(CatalogTableID id
)
103 return sysDB_
->getSystemDatabaseChunk(id
);
107 TableImpl() { db_
= NULL
; chunkPtr_
= NULL
; iter
= NULL
;
108 idxInfo
= NULL
; indexPtr_
= NULL
; scanType_
= unknownScan
; pred_
= NULL
;}
111 void setDB(Database
*db
) { db_
= db
; }
112 void setSystemDB(Database
*db
) { sysDB_
= db
; }
113 void setLockManager(LockManager
*lmgr
) { lMgr_
= lmgr
; }
114 void setTrans(Transaction
**t
) { trans
= t
; }
116 DataType
getFieldType(const char *name
)
117 { return fldList_
.getFieldType(name
); }
118 int getFieldOffset(const char *name
)
119 { return fldList_
.getFieldOffset(name
); }
120 size_t getFieldLength(const char *name
)
121 { return fldList_
.getFieldLength(name
); }
123 DbRetVal
getFieldInfo(const char *fieldName
, FieldInfo
*&info
)
124 { return fldList_
.getFieldInfo(fieldName
, info
); }
126 FieldNameList
getFieldNameList();
129 void setCondition(Condition
*p
)
130 { if (p
) { pred_
= p
->getPredicate(); }else pred_
= NULL
;}
133 void bindFld(const char *name
, void *val
);
135 void markFldNull(const char *name
);
136 void markFldNull(int colpos
);
137 bool isFldNull(const char *name
);
138 bool isFldNull(int colpos
);
141 void clearFldNull(const char *name);
142 void clearFldNull(int colpos);
145 DbRetVal
insertTuple();
146 DbRetVal
updateTuple();
147 DbRetVal
deleteTuple();
162 void setTableInfo(char *name
, int tblid
, size_t length
,
163 int numFld
, int numIdx
, void *chunk
);
164 friend class DatabaseManagerImpl
;