allocator fixes
[csql.git] / include / JoinTableImpl.h
blobbacbe1ae0ba6a9041c3f357e15321146a77dfb98
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
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. *
9 * *
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. *
14 * *
15 ***************************************************************************/
16 #ifndef JOINTABLE_IMPL_H
17 #define JOINTABLE_IMPL_H
18 #include<os.h>
19 #include<DataType.h>
20 #include<Transaction.h>
21 #include<Database.h>
22 #include<Index.h>
23 #include<CatalogTables.h>
24 #include<Info.h>
25 #include<Debug.h>
26 #include<DatabaseManagerImpl.h>
27 #include<Predicate.h>
29 #ifndef JOINTYPE
30 #define JOINTYPE
31 enum JoinType
33 INNER_JOIN = 1,
34 LEFT_JOIN,
35 RIGHT_JOIN,
36 FULL_JOIN,
37 UNKNOWN_JOIN
39 #endif
41 class JoinProjFieldInfo
43 public:
44 char tabFieldName[IDENTIFIER_LENGTH*2];
45 char tableName[IDENTIFIER_LENGTH];
46 char fieldName[IDENTIFIER_LENGTH];
47 DataType type;
48 int length;
49 void *appBuf;
50 void *bindBuf;
51 JoinProjFieldInfo()
53 strcpy(tableName,""); strcpy(fieldName, "");
54 type= typeUnknown; length =0; appBuf= NULL; bindBuf=NULL;
57 class JoinCondition
59 public:
60 char tableName1[IDENTIFIER_LENGTH];
61 char tableName2[IDENTIFIER_LENGTH];
62 char fieldName1[IDENTIFIER_LENGTH];
63 char fieldName2[IDENTIFIER_LENGTH];
64 DataType type1;
65 DataType type2;
66 int length1;
67 int length2;
68 void *bindBuf1;
69 void *bindBuf2;
70 bool alreadyBinded1;
71 bool alreadyBinded2;
72 ComparisionOp op;
73 JoinCondition()
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
85 private:
86 void *curTuple; //holds the current tuple ptr. moved during fetch() calls
87 List projList;
88 Table *leftTableHdl;
89 Table *rightTableHdl;
90 bool availableLeft;
91 bool isFirstFetch;
92 bool isReturnNull;
93 bool isOuterJoin;
94 bool isLeftRecOver;
95 bool isFirstCall;
96 bool leftSideFail;
98 JoinType jType;
99 ListIterator rsIter;
100 bool isNestedLoop;
101 bool rightExhausted;
102 DbRetVal copyValuesToBindBuffer(void *tuple);
103 JoinCondition jCondition;
104 Predicate *pred;
105 List predList;
107 public:
108 JoinTableImpl();
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; }
118 //binding
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;}
151 //bool evaluate();
152 DbRetVal execute();
153 void* fetch();
154 void* fetchInt();
155 void* fetch(DbRetVal &rv);
156 void* fetchNoBind();
157 void* fetchNoBind(DbRetVal &rv);
158 DbRetVal close();
160 long numTuples();
161 void printInfo();
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);
168 DbRetVal optimize();
169 void optimizeRestrict();
170 ScanType getScanType();
171 bool hasIndex(char *fname){ return false; }
172 void* getBindedBuf(char* tName, char*fName);
176 #endif