code reorg
[csql.git] / src / storage / PredicateImpl.cxx
blobac3eeb918a52e5cec63e64b6f0e2d0c7333fa09e
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 #include<Table.h>
17 #include<Index.h>
18 #include<CatalogTables.h>
19 #include<Lock.h>
20 #include<Debug.h>
21 #include<PredicateImpl.h>
22 #include<Table.h>
23 #include<TableImpl.h>
24 #include<JoinTableImpl.h>
25 #include<Util.h>
26 static char aggNames[][10] =
28 "MIN", "MAX", "SUM", "AVG", "COUNT", ""
31 PredicateImpl::~PredicateImpl()
33 // if (lhs) {delete lhs; lhs = NULL; }
34 // if (rhs) { delete rhs; rhs = NULL; }
36 void PredicateImpl::print(int space)
38 char spaceBuf[IDENTIFIER_LENGTH];
39 memset(spaceBuf, 32, IDENTIFIER_LENGTH);
40 spaceBuf[space] = '\0';
42 printf("%s <PREDICATE>\n", spaceBuf);
43 if (0 != strcmp(fldName1, "")) {
44 if (aggType == AGG_UNKNOWN)
45 printf("%s <FieldName1> %s </FieldName1>\n", spaceBuf, fldName1);
46 else
47 printf("%s <FieldName1> %s(%s) </FieldName1>\n", spaceBuf,
48 aggNames[aggType-1], fldName1);
50 if (0 != strcmp(fldName2, ""))
51 printf("%s <FieldName2> %s </FieldName2>\n", spaceBuf, fldName2);
52 if (compOp != OpInvalidComparisionOp)
53 printf("%s <CompOp> %s </CompOp>\n", spaceBuf, CompOpNames[compOp]);
54 if (logicalOp != OpInvalidLogicalOp)
55 printf("%s <LogOp> %s </LogOp>\n", spaceBuf, LogOpNames[logicalOp]);
56 if (operand) printf("%s <Operand> VALUE </Operand>\n", spaceBuf);
57 if (operandPtr) printf("%s <OperandPtr> VALUE </OperandPtr>\n", spaceBuf);
58 if (comp2Op != OpInvalidComparisionOp)
59 printf("%s <Comp2Op> %s </Comp2Op>\n", spaceBuf, CompOpNames[comp2Op]);
60 if (operand2) printf("%s <Operand2> VALUE </Operand2>\n", spaceBuf);
61 if (operand2Ptr) printf("%s <Operand2Ptr> VALUE </Operand2Ptr>\n", spaceBuf);
62 //TEMP
63 //printf("<ISPUSHEDDOWN> %d </ISPUSHEDDOWN>\n", isPushedDown);
65 if (lhs) {
66 printf("%s <PRED-LEFT>\n", spaceBuf);
67 lhs->print(space+2);
68 printf("%s </PRED-LEFT>\n", spaceBuf);
70 if (rhs)
72 printf("%s <PRED-RIGHT>\n", spaceBuf);
73 rhs->print(space+2);
74 printf("%s </PRED-RIGHT>\n", spaceBuf);
76 printf("%s </PREDICATE>\n", spaceBuf);
80 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op,
81 const char *fName2)
83 strcpy(fldName1, fName1);
84 strcpy(fldName2, fName2);
85 compOp = op;
86 operand = NULL;
87 operandPtr = NULL;
88 lhs = rhs = NULL;
89 parent = NULL;
90 logicalOp = OpInvalidLogicalOp;
91 comp2Op = OpInvalidComparisionOp;
92 operand2 =NULL;
93 operand2Ptr = NULL;
96 //Operand should be of the same type of the field.This is must
97 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op, void *opnd)
99 strcpy(fldName1, fName1);
100 compOp = op;
101 operand = opnd;
102 operandPtr = NULL;
103 lhs = rhs = NULL;
104 parent = NULL;
105 logicalOp = OpInvalidLogicalOp;
106 comp2Op = OpInvalidComparisionOp;
107 operand2 =NULL;
108 operand2Ptr = NULL;
110 void PredicateImpl::setTerm(Expression *exp, ComparisionOp op, void **opnd)
112 compOp = op;
113 lhs = rhs = NULL;
114 operandPtr = opnd;
115 operand = NULL;
116 logicalOp = OpInvalidLogicalOp;
117 comp2Op = OpInvalidComparisionOp;
118 operand2 =NULL;
119 operand2Ptr = NULL;
120 lExp = exp;
122 void PredicateImpl::setTerm(Expression *exp1, ComparisionOp op, Expression *exp2)
124 compOp = op;
125 lhs = rhs = NULL;
126 operandPtr = NULL;
127 operand = NULL;
128 logicalOp = OpInvalidLogicalOp;
129 comp2Op = OpInvalidComparisionOp;
130 operand2 =NULL;
131 operand2Ptr = NULL;
132 lExp = exp1;
133 rExp = exp2;
135 void PredicateImpl::setTerm(Expression *exp, ComparisionOp op, const char *fName2 )
137 strcpy(fldName2, fName2);
138 compOp = op;
139 operand = NULL;
140 operandPtr = NULL;
141 lhs = rhs = NULL;
142 parent = NULL;
143 logicalOp = OpInvalidLogicalOp;
144 comp2Op = OpInvalidComparisionOp;
145 operand2 =NULL;
146 operand2Ptr = NULL;
147 lExp = exp;
148 return;
151 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op,bool nullFlag)
153 strcpy(fldName1, fName1);
154 compOp = op;
155 isNull = nullFlag;
156 lhs = rhs = NULL;
157 operandPtr = NULL;
158 operand = NULL;
159 logicalOp = OpInvalidLogicalOp;
160 comp2Op = OpInvalidComparisionOp;
161 operand2 =NULL;
162 operand2Ptr = NULL;
165 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op, void **opnd)
167 strcpy(fldName1, fName1);
168 compOp = op;
169 operand = NULL;
170 operandPtr = opnd;
171 lhs = rhs = NULL;
172 parent = NULL;
173 logicalOp = OpInvalidLogicalOp;
174 comp2Op = OpInvalidComparisionOp;
175 operand2 =NULL;
176 operand2Ptr = NULL;
178 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op, void **opnd, AggType aType)
180 strcpy(fldName1, fName1);
181 compOp = op;
182 operand = NULL;
183 operandPtr = opnd;
184 lhs = rhs = NULL;
185 parent = NULL;
186 aggType = aType;
187 logicalOp = OpInvalidLogicalOp;
188 comp2Op = OpInvalidComparisionOp;
189 operand2 =NULL;
190 operand2Ptr = NULL;
193 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op, void **opnd,
194 ComparisionOp op2, void **opnd2)
196 strcpy(fldName1, fName1);
197 compOp = op;
198 operand = NULL;
199 operandPtr = opnd;
200 lhs = rhs = NULL;
201 parent = NULL;
202 logicalOp = OpInvalidLogicalOp;
204 comp2Op = op2;
205 operand2=NULL;
206 operand2Ptr = opnd2;
209 void PredicateImpl::setParent(PredicateImpl *pImpl)
211 //if (parent != NULL) printf("Parent already set\n");
212 parent = pImpl;
213 return;
215 void PredicateImpl::setTerm(Predicate *p1, LogicalOp op, Predicate *p2 )
217 if (p2 == NULL && op != OpNot || op == OpNot && p2 != NULL)
219 //TODO::printError
220 printError(ErrBadArg, "Wrong argument passed\n");
221 return;
223 lhs = (PredicateImpl*)p1;
224 rhs = (PredicateImpl*)p2;
225 logicalOp = op;
226 compOp = OpInvalidComparisionOp;
227 if (lhs != NULL) lhs->setParent(this);
228 if (rhs != NULL) rhs->setParent(this);
229 return;
232 void PredicateImpl::setTable(Table *tbl)
234 if (NULL != lhs)
235 lhs->setTable(tbl);
236 if (NULL != rhs)
237 rhs->setTable(tbl);
238 table = tbl;
240 void PredicateImpl::setIfNoLeftRight()
242 if (NULL != lhs)
243 lhs->setIfNoLeftRight();
244 if (NULL != rhs)
245 rhs->setIfNoLeftRight();
246 if(NULL == lhs && NULL == rhs) isNoLeftRight=true;
247 return;
250 void PredicateImpl::setTuple(void *tpl)
252 if (isNoLeftRight) {
253 tuple=tpl;
254 return;
256 if (NULL != lhs)
257 lhs->setTuple(tpl);
258 if (NULL != rhs)
259 rhs->setTuple(tpl);
260 tuple = tpl;
262 void PredicateImpl::setProjectionList(List *lst)
264 if (NULL != lhs)
265 lhs->setProjectionList(lst);
266 if (NULL != rhs)
267 rhs->setProjectionList(lst);
268 projList = lst;
269 isBindBufSet = false;
271 bool PredicateImpl::isSingleTerm()
273 if (NULL == lhs && NULL == rhs && comp2Op == OpInvalidComparisionOp)
274 return true;
275 return false;
278 bool PredicateImpl::appendIfSameFld(char *fName, ComparisionOp op, void *buf)
280 char fieldName1[IDENTIFIER_LENGTH];
281 Table::getFieldNameAlone(fldName1, fieldName1);
282 if (strcmp(fName,fieldName1) == 0)
284 printDebug(DM_Predicate, "Field name matched");
286 //switching so that in case of joins, first other conditions are
287 //evaluated first and then matching tuples for join is evaluated
288 //otherwise it may give wrong result set
289 if (operand) {operand2 = operand; operand2Ptr = NULL; }
290 if (operandPtr) {operand2Ptr = operandPtr; operand2 = NULL; }
291 comp2Op = compOp;
292 compOp = op;
293 operand = buf;
294 operandPtr = NULL;
296 comp2Op = op;
297 operand2 = buf;
299 return true;
301 return false;
303 bool PredicateImpl::isIsNullInvolved()
305 bool lhsResult = true, rhsResult = true;
306 if (NULL != lhs)
308 lhsResult = lhs->isIsNullInvolved();
310 if (NULL != rhs)
312 rhsResult = rhs->isIsNullInvolved();
314 if (NULL != lhs)
316 if (lhsResult || rhsResult) return true;
317 if(compOp == isNull) return true;
319 return false;
321 bool PredicateImpl::isNotOrInvolved()
323 bool lhsResult = true, rhsResult = true;
324 if (NULL != lhs)
326 lhsResult = lhs->isNotOrInvolved();
328 if (NULL != rhs)
330 rhsResult = rhs->isNotOrInvolved();
332 if (NULL != lhs)
334 //Means it involves only Logical operator
335 switch(logicalOp)
337 case OpAnd:
338 if (lhsResult || rhsResult) return true; else return false;
339 break;
340 case OpOr:
341 return true;
342 break;
343 case OpNot:
344 default:
345 return true;
346 break;
349 return false;
352 void* PredicateImpl::getValIfPointLookupOnInt(int &offset)
353 { //perf opt
354 if (NULL != lhs && NULL != rhs) return NULL;
355 if(typeInt != type || comp2Op !=OpInvalidComparisionOp) return NULL;
356 if (compOp != OpEquals) return NULL;
357 offset = offset1;
358 void *val =NULL;
359 if(operand == NULL && operandPtr != NULL)
361 val = *(void**)operandPtr;
362 } else if(operand != NULL && operandPtr == NULL)
364 val = (void*) operand;
366 return val;
368 void* PredicateImpl::getVal1IfBetweenOnInt(int &offset)
369 { //perf opt
370 if (NULL != lhs && NULL != rhs) return NULL;
371 if(typeInt != type) return NULL;
372 if (compOp != OpGreaterThanEquals ||
373 comp2Op !=OpLessThanEquals) return NULL;
374 offset = offset1;
375 void *val =NULL;
376 if(operand == NULL && operandPtr != NULL)
378 val = *(void**)operandPtr;
379 } else if(operand != NULL && operandPtr == NULL)
381 val = (void*) operand;
383 return val;
385 void* PredicateImpl::getVal2IfBetweenOnInt(int &offset)
386 { //perf opt
387 if (NULL != lhs && NULL != rhs) return NULL;
388 if(typeInt != type) return NULL;
389 if (compOp != OpGreaterThanEquals ||
390 comp2Op !=OpLessThanEquals) return NULL;
391 offset = offset1;
392 void *val =NULL;
393 if(operand2 == NULL && operand2Ptr != NULL)
395 val = *(void**)operand2Ptr;
396 } else if(operand2 != NULL && operand2Ptr == NULL)
398 val = (void*) operand2;
400 return val;
403 void PredicateImpl::solveForProjList(Table *tab)
405 if (NULL != lhs)
407 lhs->solveForProjList(tab);
409 if (NULL != rhs)
411 rhs->solveForProjList(tab);
413 table = tab;
414 if (NULL != lhs) return ;
415 bool isExist1=false;
416 bool isExist2=false;
417 if (projList)
419 ListIterator fIter = projList->getIterator();
420 JoinProjFieldInfo *def;
421 while (fIter.hasElement())
423 def = (JoinProjFieldInfo*) fIter.nextElement();
424 if (!isExist1 && 0 == strcmp(fldName1, def->tabFieldName))
426 isExist1=true;
428 if (!isExist2 && 0 == strcmp(fldName2, def->tabFieldName) )
430 isExist2=true;
433 if (!isExist1)
435 tab->bindFld(fldName1, NULL);
437 if (!isExist2 && strcmp(fldName2, "")!=0)
439 tab->bindFld(fldName2, NULL);
444 void PredicateImpl::setOffsetAndType()
446 if (NULL != lhs)
448 lhs->setOffsetAndType();
450 if (NULL != rhs)
452 rhs->setOffsetAndType();
454 char fieldName1[IDENTIFIER_LENGTH];
455 char fieldName2[IDENTIFIER_LENGTH];
456 memset(fieldName1, 0, IDENTIFIER_LENGTH);
457 memset(fieldName2, 0, IDENTIFIER_LENGTH);
458 Table::getFieldNameAlone(fldName1, fieldName1);
459 Table::getFieldNameAlone(fldName2, fieldName2);
460 //this function is called only from TableImpl
461 TableImpl *tImpl = (TableImpl*) table;
462 if(fieldName1){
463 FieldInfo *info = new FieldInfo();
464 tImpl->getFieldInfo(fieldName1, info);
465 offset1 = tImpl->getFieldOffset(fieldName1);
466 fldPos = tImpl->getFldPos(fieldName1);
467 type = info->type;
468 length = info->length;
469 isNullable = true;
470 if (info->isNull || info->isPrimary || info->isAutoIncrement)
471 isNullable = false;
472 //printf("isNullable is set to %d\n", isNullable);
473 delete info;
476 if(fieldName2){
477 offset2 = tImpl->getFieldOffset(fieldName2);
478 if(typeUnknown == type)
479 type = tImpl->getFieldType(fieldName2);
484 bool PredicateImpl::pointLookupInvolved(const char *fname)
486 bool rhsResult, lhsResult;
487 if (NULL != lhs)
489 lhsResult = lhs->pointLookupInvolved(fname);
491 if (NULL != rhs)
493 rhsResult = rhs->pointLookupInvolved(fname);
495 if (NULL != lhs)
497 //Means it involves only Logical operator
498 switch(logicalOp)
500 case OpAnd:
501 //return lhsResult;
502 if (lhsResult || rhsResult) return true; else return false;
503 break;
504 case OpOr:
505 return false;
506 break;
507 case OpNot:
508 default:
509 return false;
510 break;
513 //Means it is relational expression
514 //first operand is always field identifier
515 char fieldName1[IDENTIFIER_LENGTH];
516 Table::getFieldNameAlone(fldName1, fieldName1);
517 if (OpEquals == compOp)
519 //for expressions f1 == f2 use full scan, so return false
520 if(NULL == operand && NULL == operandPtr) return false;
521 if(0 == strcmp(fieldName1, fname))
523 return true;
526 return false;
529 bool PredicateImpl::isBetweenInvolved(const char *fname)
531 bool rhsResult, lhsResult;
532 if (NULL != lhs)
534 lhsResult = lhs->isBetweenInvolved(fname);
536 if (NULL != rhs)
538 rhsResult = rhs->isBetweenInvolved(fname);
540 if (NULL != lhs)
542 switch(logicalOp)
544 case OpAnd:
545 if (lhsResult && rhsResult) return true; else return false;
546 break;
547 default:
548 return false;
549 break;
552 char fieldName1[IDENTIFIER_LENGTH];
553 Table::getFieldNameAlone(fldName1, fieldName1);
554 if ( OpGreaterThan == compOp || OpGreaterThanEquals == compOp)
556 if(0 == strcmp(fieldName1, fname))
558 return true;
561 return false;
564 bool PredicateImpl::rangeQueryInvolved(const char *fname)
566 bool rhsResult, lhsResult;
567 if (NULL != lhs)
569 lhsResult = lhs->rangeQueryInvolved(fname);
571 if (NULL != rhs)
573 rhsResult = rhs->rangeQueryInvolved(fname);
575 if (NULL != lhs)
577 switch(logicalOp)
579 case OpAnd:
580 if (lhsResult || rhsResult) return true; else return false;
581 break;
582 case OpOr:
583 return false;
584 break;
585 case OpNot:
586 default:
587 return false;
588 break;
591 //Means it is relational expression
592 //first operand is always field identifier
593 char fieldName1[IDENTIFIER_LENGTH];
594 Table::getFieldNameAlone(fldName1, fieldName1);
595 if (OpLessThan == compOp || OpLessThanEquals == compOp ||
596 OpGreaterThan == compOp || OpGreaterThanEquals == compOp)
598 //for expressions f1 == f2 use full scan, so return false
599 if(NULL == operand && NULL == operandPtr) return false;
600 if(0 == strcmp(fieldName1, fname))
602 return true;
605 return false;
608 void* PredicateImpl::opAndValPtrForIndexField(const char *fname, bool isUnique,ComparisionOp &op)
610 ComparisionOp lhsOp= OpInvalidComparisionOp, rhsOp= OpInvalidComparisionOp;
611 void *lhsRet=NULL, *rhsRet=NULL;
612 if (NULL != lhs)
614 lhsRet = lhs->opAndValPtrForIndexField(fname, isUnique, lhsOp);
616 if (NULL != rhs)
618 rhsRet = rhs->opAndValPtrForIndexField(fname, isUnique,rhsOp);
620 if (lhsRet && lhsOp == OpEquals) { op = lhsOp; return lhsRet;}
621 if (rhsRet && rhsOp == OpEquals) { op = rhsOp; return rhsRet;}
622 if (NULL != lhs)
624 if( lhsRet) { op = lhsOp; return lhsRet; }
625 if( rhsRet) { op = rhsOp; return rhsRet; }
627 char fieldName1[IDENTIFIER_LENGTH];
628 Table::getFieldNameAlone(fldName1, fieldName1);
629 //Means it is relational expression
630 //first operand is always field identifier
631 if(0 == strcmp(fieldName1, fname))
633 op = compOp;
634 if (isUnique && compOp != OpLessThan &&
635 compOp != OpLessThanEquals &&
636 compOp != OpNotEquals ) isPushedDown = true;
637 if (operand) return operand; else return *(void**)operandPtr;
639 op = OpInvalidComparisionOp;
640 return NULL;
644 //called only in case of hash index scan
645 void* PredicateImpl::valPtrForIndexField(const char *fname, bool isUnique)
647 void *lhsRet=NULL, *rhsRet=NULL;
648 if (NULL != lhs)
650 lhsRet = lhs->valPtrForIndexField(fname, isUnique);
651 if ( lhsRet != NULL) return lhsRet;
653 if (NULL != rhs)
655 rhsRet = rhs->valPtrForIndexField(fname, isUnique);
656 if ( rhsRet != NULL) return rhsRet;
658 char fieldName1[IDENTIFIER_LENGTH];
659 Table::getFieldNameAlone(fldName1, fieldName1);
660 //Means it is relational expression
661 //first operand is always field identifier
662 if (OpEquals == compOp)
664 if(0 == strcmp(fieldName1, fname))
666 if (isUnique) isPushedDown = true;
667 if (operand) return operand; else return *(void**)operandPtr;
670 return NULL;
672 ComparisionOp PredicateImpl::opForIndexField(const char *fname)
674 ComparisionOp lhsRet= OpInvalidComparisionOp, rhsRet= OpInvalidComparisionOp;
675 if (NULL != lhs)
677 lhsRet = lhs->opForIndexField(fname);
678 if ( lhsRet != OpInvalidComparisionOp) return lhsRet;
681 if (NULL != rhs)
683 rhsRet = rhs->opForIndexField(fname);
684 if ( rhsRet != OpInvalidComparisionOp) return rhsRet;
686 char fieldName1[IDENTIFIER_LENGTH];
687 Table::getFieldNameAlone(fldName1, fieldName1);
688 if(0 == strcmp(fieldName1, fname))
690 return compOp;
692 return OpInvalidComparisionOp;
694 PredicateImpl* PredicateImpl::getTablePredicate()
696 PredicateImpl *lhsRet = NULL, *rhsRet = NULL;
697 if (NULL != lhs)
699 lhsRet = lhs->getTablePredicate();
700 if ( lhsRet != NULL) return lhsRet;
702 if (NULL != rhs)
704 rhsRet = rhs->getTablePredicate();
705 if ( rhsRet != NULL) return rhsRet;
707 if (operand || operandPtr )
709 //printf("PRABA::getTablePredicate returning %s %d\n", fldName1, compOp);
710 if (parent)
712 if (this == parent->lhs) {
713 parent->lhs = NULL;
715 else {
716 parent->rhs = NULL;
718 parent = NULL;
720 return this;
722 return NULL;
724 PredicateImpl* PredicateImpl::getJoinPredicate()
726 PredicateImpl *lhsRet = NULL, *rhsRet = NULL;
727 if (NULL != lhs)
729 lhsRet = lhs->getJoinPredicate();
730 if ( lhsRet != NULL) return lhsRet;
732 if (NULL != rhs)
734 rhsRet = rhs->getJoinPredicate();
735 if ( rhsRet != NULL) return rhsRet;
737 if (0 != strcmp(fldName2, ""))
739 //printf("PRABA::getJoinPredicate returning %s %s\n", fldName1, fldName2);
740 if (parent)
742 if (this == parent->lhs)
743 parent->lhs = NULL;
744 else
745 parent->rhs = NULL;
746 parent = NULL;
748 return this;
750 return NULL;
752 void PredicateImpl::removeIfNotNecessary()
754 if (NULL != lhs)
756 lhs->removeIfNotNecessary();
758 if (NULL != rhs)
760 rhs->removeIfNotNecessary();
762 if (logicalOp != OpAnd) return;
763 if (NULL == lhs && NULL == rhs)
765 if (NULL == parent)
767 return;
769 if (this == parent->rhs) parent->rhs = NULL;
770 else if (this == parent->lhs) parent->lhs = NULL;
771 //TODO::PRABA::fix the leak below. if uncommented dumps core
772 //delete this;
773 //WARNINGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
774 //current object is deleted. do not any code here
775 return;
777 else if (NULL == lhs )
779 //left side of the node is empty means we can remove this AND node
780 //and place it as left or right of my parent where i am currently placed
781 if (NULL == parent)
783 return;
785 if (this == parent->rhs) parent->rhs=this->rhs;
786 else if (this == parent->lhs) parent->lhs = this->rhs;
787 //TODO::PRABA::fix the leak below. if uncommented dumps core
788 //delete this;
789 //WARNINGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
790 //current object is deleted. do not any code here
791 return;
793 else if (NULL == rhs )
795 //right side of the node is empty means we can remove this AND node
796 //and place it as left or right of my parent where i am currently placed
797 if (NULL == parent)
799 return;
801 if (this == parent->rhs) parent->rhs=this->lhs;
802 else if (this == parent->lhs) parent->lhs = this->lhs;
803 //TODO::PRABA::fix the leak below. if uncommented dumps core
804 //delete this;
805 //WARNINGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
806 //current object is deleted. do not any code here
807 return;
809 return;
811 bool PredicateImpl::isDummyPredicate()
813 if (NULL == lhs && NULL == rhs && NULL == parent
814 && NULL == operand && NULL == operandPtr &&
815 (0 == strcmp(fldName1, "")) && (0==strcmp(fldName2, "")))
816 return true;
817 else
818 return false;
820 PredicateImpl* PredicateImpl::getIfOneSidedPredicate()
822 if (logicalOp != OpAnd) return NULL;
823 if (NULL == lhs && NULL !=rhs)
825 return rhs;
827 if (NULL != lhs && NULL ==rhs)
829 return lhs;
831 return NULL;