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 ***************************************************************************/
16 #ifndef AGGTABLE_IMPL_H
17 #define AGGTABLE_IMPL_H
20 #include<Transaction.h>
23 #include<CatalogTables.h>
26 #include<DatabaseManagerImpl.h>
28 #include<HeapAllocator.h>
46 char fldName
[IDENTIFIER_LENGTH
];
67 class AggTableImpl
:public Table
70 char tblName_
[IDENTIFIER_LENGTH
];
71 void *curTuple
; //holds the current tuple ptr. moved during fetch() calls
75 List aggNodes
; //change this list to some other data structure
76 ListIterator aggNodeIter
;
77 HashMap aggNodeMap
; //for faster lookup
78 Predicate
*havingPred
;
80 long long prjNullInfo
;
88 DbRetVal
copyValuesToBindBuffer(void *tuple
);
91 virtual ~AggTableImpl();
92 DbRetVal
getFieldInfo(const char *fieldName
, FieldInfo
*&info
)
93 { return tableHdl
->getFieldInfo(fieldName
, info
); }
94 void* insertOrGetAggNode();
95 void setTable(Table
*impl
){ tableHdl
= impl
;}
96 Table
* getTableHdl(){ return tableHdl
; }
98 void *getBindFldAddr(const char *name
);
99 DbRetVal
bindFld(const char *name
, void *val
, bool dummy
=false);
100 DbRetVal
bindFld(const char *name
, AggType aggType
, void *val
);
101 DbRetVal
setGroup(const char *name
, void *val
);
102 bool isFldPresentInGrp(char *fname
);
103 int computeGrpNodeSize();
104 void* getGroupValueBuffer();
105 int getAggOffset(char *fname
, AggType aggType
);
106 DbRetVal
copyValuesFromGrpBindBuf(char *grpFldBuf
, char *fldName
);
107 void setCondition(Condition
*p
){ havingPred
= p
->getPredicate();}
108 DbRetVal
markFldNull(const char *name
){ return OK
;}
109 inline DbRetVal
markFldNull(int colpos
){
110 SETBIT(grpNullInfo
, colpos
-1);
113 bool isFldNull(const char *name
);
114 inline bool isFldNull(int colpos
) {
115 if (colpos
<= 32) { if (BITSET(prjNullInfo
, colpos
-1)) return true; }
116 else if (BITSET(*(int *)((char *)&prjNullInfo
+ 4), colpos
-1))
120 void clearFldNull(const char *name
){}
121 inline void clearFldNull(int colpos
){
122 if (colpos
<= 32) CLEARBIT(prjNullInfo
, colpos
-1);
123 else CLEARBIT(*(int *)((char*)&prjNullInfo
+ 4), colpos
-1);
125 DbRetVal
compact(){ return OK
;}
126 int getFldPos(char *name
){ return 0;}
127 void resetNullinfo(){}
128 DbRetVal
insertTuple() { return ErrBadCall
; }
129 DbRetVal
updateTuple() { return ErrBadCall
; }
130 DbRetVal
deleteTuple() { return ErrBadCall
; }
131 int deleteWhere() { return ErrBadCall
; }
132 int truncate() { return ErrBadCall
; }
133 long spaceUsed() { return 0; }
134 int pagesUsed() { return 0; }
135 DbRetVal
lock(bool shared
) { return ErrBadCall
; }
136 DbRetVal
unlock(){ return ErrBadCall
; }
137 DbRetVal
setUndoLogging(bool flag
) { return ErrBadCall
; }
138 void printSQLIndexString(FILE *fp
, int fd
){ };
139 void printSQLForeignString(){}
140 char* getName() { return tableHdl
->getName(); }
141 char* getAliasName(){ return tableHdl
->getAliasName();}
142 List
getFieldNameList(){ List list
; return list
;}
145 void* fetch(DbRetVal
&rv
);
147 void* fetchNoBind(DbRetVal
&rv
);
151 bool pushPredicate(Predicate
*pred
)
152 { printf("Wrong call\n"); return false; }
153 void setPredicate(Predicate
*pred
)
154 { printf("Wrong call\n"); }
155 bool isTableInvolved(char *tableName
)
156 { printf("Wrong call\n"); return false; }
157 void printPlan(int space
);
159 bool isFKTable(){return false;}
160 ScanType
getScanType(){ return unknownScan
;}
161 bool hasIndex(char *fName
){ return false;}
162 AggType
getAggType(const char *aggName
, char *fldName
);