Testing Commit in autocommit mode
[csql.git] / include / PredicateImpl.h
blob1b39e06d03a09e0f5dbd5a793308b047df8cb27b
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 PREDICATE_IMPL_H
17 #define PREDICATE_IMPL_H
18 #include<DataType.h>
19 #include<Predicate.h>
20 #include<ErrorType.h>
21 class TableImpl;
22 class Table;
23 class List;
24 class PredicateImpl:public Predicate
26 //Members set during initialization of the term
27 char fldName1[IDENTIFIER_LENGTH];
28 char fldName2[IDENTIFIER_LENGTH];
29 ComparisionOp compOp;
30 void *operand;
31 void **operandPtr;
32 LogicalOp logicalOp;
33 PredicateImpl *lhs;
34 PredicateImpl *rhs;
36 //Members set during execution
37 void *tuple; //pointer to the tuple
38 List *projList;
40 //This will be set before calling evaluate
41 TableImpl *table;
43 public:
44 PredicateImpl()
46 strcpy(fldName1, ""); strcpy(fldName2, "");
47 operand = NULL; operandPtr = NULL; lhs = rhs = NULL;
48 tuple = NULL; table = NULL;
49 projList = NULL;
51 ~PredicateImpl(){}
53 void setTerm(const char* fName1, ComparisionOp op, const char *fName2);
55 //Operand should be of the same type of the field.This is must
56 void setTerm(const char* fName1, ComparisionOp op, void *opnd);
58 void setTerm(const char* fName1, ComparisionOp op, void **opnd);
61 void setTerm(Predicate *p1, LogicalOp op, Predicate *p2 = NULL);
63 void* valPtrForIndexField(const char *name);
64 ComparisionOp opForIndexField(const char *name);
66 DbRetVal evaluate(bool &result);
68 void setTable(Table *tbl);
69 void setTuple(void *tpl);
70 void setProjectionList(List *list); //used by JoinTableImpl
72 bool isSingleTerm();
73 bool isNotOrInvolved();
74 //check predicate, whether it has field name and == operator
75 //and does not have OR, NOT operator
76 // TODO:: expression like !(f1 !=100) wont be optimized for now
77 bool pointLookupInvolved(const char *fName);
78 bool rangeQueryInvolved(const char *fName);
80 void print();
84 #endif