Fixing failed test cache/DDL/test001.ksh
[csql.git] / include / JoinTableImpl.h
blob17cb6c972ab81cf50f1fa73393d609242a4f7fee
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; }
104 void 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 void markFldNull(const char *name){}
115 void 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 DbRetVal insertTuple() { return ErrBadCall; }
121 DbRetVal updateTuple() { return ErrBadCall; }
122 DbRetVal deleteTuple() { return ErrBadCall; }
123 int deleteWhere() { return ErrBadCall; }
124 int truncate() { return ErrBadCall; }
125 long spaceUsed() { return 0; }
126 int pagesUsed() { return 0; }
127 DbRetVal lock(bool shared) { return ErrBadCall; }
128 DbRetVal unlock(){ return ErrBadCall; }
129 DbRetVal setUndoLogging(bool flag) { return ErrBadCall; }
130 void printSQLIndexString(){ };
131 List getFieldNameList();
132 char* getName() { return NULL; }
134 bool evaluate();
135 DbRetVal execute();
136 void* fetch();
137 void* fetch(DbRetVal &rv);
138 void* fetchNoBind();
139 void* fetchNoBind(DbRetVal &rv);
140 DbRetVal close();
142 long numTuples();
143 void printInfo();
144 void *getBindFldAddr(const char *name);
149 #endif