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 JOINTABLE_IMPL_H
17 #define JOINTABLE_IMPL_H
20 #include<Transaction.h>
23 #include<CatalogTables.h>
26 #include<DatabaseManagerImpl.h>
41 class JoinProjFieldInfo
44 char tabFieldName
[IDENTIFIER_LENGTH
*2];
45 char tableName
[IDENTIFIER_LENGTH
];
46 char fieldName
[IDENTIFIER_LENGTH
];
53 strcpy(tableName
,""); strcpy(fieldName
, "");
54 type
= typeUnknown
; length
=0; appBuf
= NULL
; bindBuf
=NULL
;
60 char tableName1
[IDENTIFIER_LENGTH
];
61 char tableName2
[IDENTIFIER_LENGTH
];
62 char fieldName1
[IDENTIFIER_LENGTH
];
63 char fieldName2
[IDENTIFIER_LENGTH
];
75 strcpy(tableName1
,""); strcpy(fieldName1
, "");
76 strcpy(tableName2
,""); strcpy(fieldName2
, "");
77 type1
= typeUnknown
; length1
=0; bindBuf1
=NULL
;
78 type2
= typeUnknown
; length2
=0; bindBuf2
=NULL
;
79 alreadyBinded1
=false; alreadyBinded2
=false;
83 class JoinTableImpl
:public Table
86 void *curTuple
; //holds the current tuple ptr. moved during fetch() calls
102 DbRetVal
copyValuesToBindBuffer(void *tuple
);
103 JoinCondition jCondition
;
109 virtual ~JoinTableImpl();
111 DbRetVal
getFieldInfo(const char *fieldName
, FieldInfo
*&info
);
113 void setTable(Table
*left
, Table
*right
)
114 { leftTableHdl
= left
; rightTableHdl
= right
; }
115 int getFldPos(char *name
){ return 0;}
116 DbRetVal
closeScan();
117 void setJoinType(JoinType type
) { jType
= type
; }
119 DbRetVal
bindFld(const char *name
, void *val
, bool dummy
=false);
120 //DbRetVal setJoinCondition(const char *fldname1, ComparisionOp op,
121 // const char *fldname2);
123 void setCondition(Condition
*p
)
124 { if (p
) pred
= p
->getPredicate(); else pred
= NULL
;}
126 DbRetVal
markFldNull(const char *name
){ return ErrBadCall
;}
127 DbRetVal
markFldNull(int colpos
){ return ErrBadCall
;}
128 bool isFldNull(const char *name
);
129 bool isFldNullInt(const char *name
);
130 bool isFldNull(int colpos
){return false;}
131 void clearFldNull(const char *name
){}
132 void clearFldNull(int colpos
){}
133 void resetNullinfo(){ }
134 DbRetVal
insertTuple() { return ErrBadCall
; }
135 DbRetVal
updateTuple() { return ErrBadCall
; }
136 DbRetVal
deleteTuple() { return ErrBadCall
; }
137 int deleteWhere() { return ErrBadCall
; }
138 int truncate() { return ErrBadCall
; }
139 long spaceUsed() { return 0; }
140 int pagesUsed() { return 0; }
141 DbRetVal
lock(bool shared
) { return ErrBadCall
; }
142 DbRetVal
unlock(){ return ErrBadCall
; }
143 DbRetVal
setUndoLogging(bool flag
) { return ErrBadCall
; }
144 void printSQLIndexString(FILE *fp
, int fd
){ };
145 void printSQLForeignString(){}
146 List
getFieldNameList();
147 char* getName() { return NULL
; }
148 char* getAliasName(){ return NULL
; }
149 void *fetchRightFail();
150 DbRetVal
compact(){ return OK
;}
155 void* fetch(DbRetVal
&rv
);
157 void* fetchNoBind(DbRetVal
&rv
);
162 void *getBindFldAddr(const char *name
);
163 bool isFKTable(){return false;}
164 bool isTableInvolved(char *tblName
);
165 bool pushPredicate(Predicate
*pred
);
166 void setPredicate(Predicate
*pred
);
167 void printPlan(int space
);
169 void optimizeRestrict();
170 ScanType
getScanType();
171 bool hasIndex(char *fname
){ return false; }
172 void* getBindedBuf(char* tName
, char*fName
);