destructor is made to call table close which will delete the table handle
[csql.git] / include / JoinTableImpl.h
blob1c8e8725f876a2da63ace8e309f4c8355af02eda
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>
28 enum JoinType
30 INNER_JOIN = 1,
31 RIGHT_JOIN,
32 LEFT_JOIN,
33 FULL_JOIN,
34 UNKNOWN_JOIN
36 class JoinProjFieldInfo
38 public:
39 char tabFieldName[IDENTIFIER_LENGTH*2];
40 char tableName[IDENTIFIER_LENGTH];
41 char fieldName[IDENTIFIER_LENGTH];
42 DataType type;
43 int length;
44 void *appBuf;
45 void *bindBuf;
46 JoinProjFieldInfo()
48 strcpy(tableName,""); strcpy(fieldName, "");
49 type= typeUnknown; length =0; appBuf= NULL; bindBuf=NULL;
52 class JoinCondition
54 public:
55 char tableName1[IDENTIFIER_LENGTH];
56 char tableName2[IDENTIFIER_LENGTH];
57 char fieldName1[IDENTIFIER_LENGTH];
58 char fieldName2[IDENTIFIER_LENGTH];
59 DataType type1;
60 DataType type2;
61 int length1;
62 int length2;
63 void *bindBuf1;
64 void *bindBuf2;
65 bool alreadyBinded1;
66 bool alreadyBinded2;
67 ComparisionOp op;
68 JoinCondition()
70 strcpy(tableName1,""); strcpy(fieldName1, "");
71 strcpy(tableName2,""); strcpy(fieldName2, "");
72 type1= typeUnknown; length1 =0; bindBuf1=NULL;
73 type2= typeUnknown; length2 =0; bindBuf2=NULL;
74 alreadyBinded1=false; alreadyBinded2=false;
78 class JoinTableImpl:public Table
80 private:
81 void *curTuple; //holds the current tuple ptr. moved during fetch() calls
82 List projList;
83 Table *leftTableHdl;
84 Table *rightTableHdl;
85 bool availableLeft;
87 JoinType jType;
88 ListIterator rsIter;
89 bool isNestedLoop;
90 bool rightExhausted;
91 DbRetVal copyValuesToBindBuffer(void *tuple);
92 JoinCondition jCondition;
93 Predicate *pred;
95 public:
96 JoinTableImpl();
97 virtual ~JoinTableImpl();
99 DbRetVal getFieldInfo(const char *fieldName, FieldInfo *&info);
101 void setTable(Table *left, Table *right)
102 { leftTableHdl = left; rightTableHdl = right; }
103 int getFldPos(char *name){}
104 DbRetVal closeScan();
105 void setJoinType(JoinType type) { jType = type; }
106 //binding
107 DbRetVal bindFld(const char *name, void *val);
108 //DbRetVal setJoinCondition(const char *fldname1, ComparisionOp op,
109 // const char *fldname2);
111 void setCondition(Condition *p)
112 { if (p) pred = p->getPredicate(); else pred = NULL;}
114 DbRetVal markFldNull(const char *name){}
115 DbRetVal markFldNull(int colpos){}
116 bool isFldNull(const char *name){return false;}
117 bool isFldNull(int colpos){return false;}
118 void clearFldNull(const char *name){}
119 void clearFldNull(int colpos){}
120 void resetNullinfo(){ }
121 DbRetVal insertTuple() { return ErrBadCall; }
122 DbRetVal updateTuple() { return ErrBadCall; }
123 DbRetVal deleteTuple() { return ErrBadCall; }
124 int deleteWhere() { return ErrBadCall; }
125 int truncate() { return ErrBadCall; }
126 long spaceUsed() { return 0; }
127 int pagesUsed() { return 0; }
128 DbRetVal lock(bool shared) { return ErrBadCall; }
129 DbRetVal unlock(){ return ErrBadCall; }
130 DbRetVal setUndoLogging(bool flag) { return ErrBadCall; }
131 void printSQLIndexString(){ };
132 List getFieldNameList();
133 char* getName() { return NULL; }
135 //bool evaluate();
136 DbRetVal execute();
137 void* fetch();
138 void* fetch(DbRetVal &rv);
139 void* fetchNoBind();
140 void* fetchNoBind(DbRetVal &rv);
141 DbRetVal close();
143 long numTuples();
144 void printInfo();
145 void *getBindFldAddr(const char *name);
147 bool isTableInvolved(char *tblName);
148 bool pushPredicate(Predicate *pred);
149 void setPredicate(Predicate *pred);
150 void printPlan(int space);
151 DbRetVal optimize();
152 void optimizeRestrict();
153 ScanType getScanType();
154 bool hasIndex(char *fname){ return false; }
155 void* getBindedBuf(char* tName, char*fName);
159 #endif