code reorg
[csql.git] / src / relational / table / PredicateImpl.cxx
blob0cac2a07966c1213a3f1a28ce533d3baddeeef94
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; }
37 void PredicateImpl::print(int space)
39 char spaceBuf[IDENTIFIER_LENGTH];
40 memset(spaceBuf, 32, IDENTIFIER_LENGTH);
41 spaceBuf[space] = '\0';
43 printf("%s <PREDICATE>\n", spaceBuf);
44 if (0 != strcmp(fldName1, "")) {
45 if (aggType == AGG_UNKNOWN)
46 printf("%s <FieldName1> %s </FieldName1>\n", spaceBuf, fldName1);
47 else
48 printf("%s <FieldName1> %s(%s) </FieldName1>\n", spaceBuf,
49 aggNames[aggType-1], fldName1);
51 if (0 != strcmp(fldName2, ""))
52 printf("%s <FieldName2> %s </FieldName2>\n", spaceBuf, fldName2);
53 if (compOp != OpInvalidComparisionOp)
54 printf("%s <CompOp> %s </CompOp>\n", spaceBuf, CompOpNames[compOp]);
55 if (logicalOp != OpInvalidLogicalOp)
56 printf("%s <LogOp> %s </LogOp>\n", spaceBuf, LogOpNames[logicalOp]);
57 if (operand) printf("%s <Operand> VALUE </Operand>\n", spaceBuf);
58 if (operandPtr) printf("%s <OperandPtr> VALUE </OperandPtr>\n", spaceBuf);
59 if (comp2Op != OpInvalidComparisionOp)
60 printf("%s <Comp2Op> %s </Comp2Op>\n", spaceBuf, CompOpNames[comp2Op]);
61 if (operand2) printf("%s <Operand2> VALUE </Operand2>\n", spaceBuf);
62 if (operand2Ptr) printf("%s <Operand2Ptr> VALUE </Operand2Ptr>\n", spaceBuf);
63 //TEMP
64 //printf("<ISPUSHEDDOWN> %d </ISPUSHEDDOWN>\n", isPushedDown);
66 if (lhs) {
67 printf("%s <PRED-LEFT>\n", spaceBuf);
68 lhs->print(space+2);
69 printf("%s </PRED-LEFT>\n", spaceBuf);
71 if (rhs)
73 printf("%s <PRED-RIGHT>\n", spaceBuf);
74 rhs->print(space+2);
75 printf("%s </PRED-RIGHT>\n", spaceBuf);
77 printf("%s </PREDICATE>\n", spaceBuf);
81 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op,
82 const char *fName2)
84 strcpy(fldName1, fName1);
85 strcpy(fldName2, fName2);
86 compOp = op;
87 operand = NULL;
88 operandPtr = NULL;
89 lhs = rhs = NULL;
90 parent = NULL;
91 logicalOp = OpInvalidLogicalOp;
92 comp2Op = OpInvalidComparisionOp;
93 operand2 =NULL;
94 operand2Ptr = NULL;
97 //Operand should be of the same type of the field.This is must
98 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op, void *opnd)
100 strcpy(fldName1, fName1);
101 compOp = op;
102 operand = opnd;
103 operandPtr = NULL;
104 lhs = rhs = NULL;
105 parent = NULL;
106 logicalOp = OpInvalidLogicalOp;
107 comp2Op = OpInvalidComparisionOp;
108 operand2 =NULL;
109 operand2Ptr = NULL;
112 void PredicateImpl::setTerm(Expression *exp, ComparisionOp op, void **opnd)
114 compOp = op;
115 lhs = rhs = NULL;
116 operandPtr = opnd;
117 operand = NULL;
118 logicalOp = OpInvalidLogicalOp;
119 comp2Op = OpInvalidComparisionOp;
120 operand2 =NULL;
121 operand2Ptr = NULL;
122 lExp = exp;
125 void PredicateImpl::setTerm(Expression *exp1, ComparisionOp op, Expression *exp2)
127 compOp = op;
128 lhs = rhs = NULL;
129 operandPtr = NULL;
130 operand = NULL;
131 logicalOp = OpInvalidLogicalOp;
132 comp2Op = OpInvalidComparisionOp;
133 operand2 =NULL;
134 operand2Ptr = NULL;
135 lExp = exp1;
136 rExp = exp2;
139 void PredicateImpl::setTerm(Expression *exp, ComparisionOp op, const char *fName2 )
141 strcpy(fldName2, fName2);
142 compOp = op;
143 operand = NULL;
144 operandPtr = NULL;
145 lhs = rhs = NULL;
146 parent = NULL;
147 logicalOp = OpInvalidLogicalOp;
148 comp2Op = OpInvalidComparisionOp;
149 operand2 =NULL;
150 operand2Ptr = NULL;
151 lExp = exp;
152 return;
155 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op,bool nullFlag)
157 strcpy(fldName1, fName1);
158 compOp = op;
159 isNull = nullFlag;
160 lhs = rhs = NULL;
161 operandPtr = NULL;
162 operand = NULL;
163 logicalOp = OpInvalidLogicalOp;
164 comp2Op = OpInvalidComparisionOp;
165 operand2 =NULL;
166 operand2Ptr = NULL;
169 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op, void **opnd)
171 strcpy(fldName1, fName1);
172 compOp = op;
173 operand = NULL;
174 operandPtr = opnd;
175 lhs = rhs = NULL;
176 parent = NULL;
177 logicalOp = OpInvalidLogicalOp;
178 comp2Op = OpInvalidComparisionOp;
179 operand2 =NULL;
180 operand2Ptr = NULL;
183 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op, void **opnd, AggType aType)
185 strcpy(fldName1, fName1);
186 compOp = op;
187 operand = NULL;
188 operandPtr = opnd;
189 lhs = rhs = NULL;
190 parent = NULL;
191 aggType = aType;
192 logicalOp = OpInvalidLogicalOp;
193 comp2Op = OpInvalidComparisionOp;
194 operand2 =NULL;
195 operand2Ptr = NULL;
198 void PredicateImpl::setTerm(const char* fName1, ComparisionOp op, void **opnd,
199 ComparisionOp op2, void **opnd2)
201 strcpy(fldName1, fName1);
202 compOp = op;
203 operand = NULL;
204 operandPtr = opnd;
205 lhs = rhs = NULL;
206 parent = NULL;
207 logicalOp = OpInvalidLogicalOp;
209 comp2Op = op2;
210 operand2=NULL;
211 operand2Ptr = opnd2;
214 void PredicateImpl::setParent(PredicateImpl *pImpl)
216 //if (parent != NULL) printf("Parent already set\n");
217 parent = pImpl;
218 return;
221 void PredicateImpl::setTerm(Predicate *p1, LogicalOp op, Predicate *p2 )
223 if (p2 == NULL && op != OpNot || op == OpNot && p2 != NULL)
225 //TODO::printError
226 printError(ErrBadArg, "Wrong argument passed\n");
227 return;
229 lhs = (PredicateImpl*)p1;
230 rhs = (PredicateImpl*)p2;
231 logicalOp = op;
232 compOp = OpInvalidComparisionOp;
233 if (lhs != NULL) lhs->setParent(this);
234 if (rhs != NULL) rhs->setParent(this);
235 return;
238 void PredicateImpl::setTable(Table *tbl)
240 if (NULL != lhs)
241 lhs->setTable(tbl);
242 if (NULL != rhs)
243 rhs->setTable(tbl);
244 table = tbl;
247 void PredicateImpl::setIfNoLeftRight()
249 if (NULL != lhs)
250 lhs->setIfNoLeftRight();
251 if (NULL != rhs)
252 rhs->setIfNoLeftRight();
253 if(NULL == lhs && NULL == rhs) isNoLeftRight=true;
254 return;
257 void PredicateImpl::setTuple(void *tpl)
259 if (isNoLeftRight) {
260 tuple=tpl;
261 return;
263 if (NULL != lhs)
264 lhs->setTuple(tpl);
265 if (NULL != rhs)
266 rhs->setTuple(tpl);
267 tuple = tpl;
270 void PredicateImpl::setProjectionList(List *lst)
272 if (NULL != lhs)
273 lhs->setProjectionList(lst);
274 if (NULL != rhs)
275 rhs->setProjectionList(lst);
276 projList = lst;
277 isBindBufSet = false;
280 bool PredicateImpl::isSingleTerm()
282 if (NULL == lhs && NULL == rhs && comp2Op == OpInvalidComparisionOp)
283 return true;
284 return false;
287 bool PredicateImpl::appendIfSameFld(char *fName, ComparisionOp op, void *buf)
289 char fieldName1[IDENTIFIER_LENGTH];
290 Table::getFieldNameAlone(fldName1, fieldName1);
291 if (strcmp(fName,fieldName1) == 0)
293 printDebug(DM_Predicate, "Field name matched");
295 //switching so that in case of joins, first other conditions are
296 //evaluated first and then matching tuples for join is evaluated
297 //otherwise it may give wrong result set
298 if (operand) {operand2 = operand; operand2Ptr = NULL; }
299 if (operandPtr) {operand2Ptr = operandPtr; operand2 = NULL; }
300 comp2Op = compOp;
301 compOp = op;
302 operand = buf;
303 operandPtr = NULL;
305 comp2Op = op;
306 operand2 = buf;
308 return true;
310 return false;
313 bool PredicateImpl::isIsNullInvolved()
315 bool lhsResult = true, rhsResult = true;
316 if (NULL != lhs)
318 lhsResult = lhs->isIsNullInvolved();
320 if (NULL != rhs)
322 rhsResult = rhs->isIsNullInvolved();
324 if (NULL != lhs)
326 if (lhsResult || rhsResult) return true;
327 if(compOp == isNull) return true;
329 return false;
332 bool PredicateImpl::isNotOrInvolved()
334 bool lhsResult = true, rhsResult = true;
335 if (NULL != lhs)
337 lhsResult = lhs->isNotOrInvolved();
339 if (NULL != rhs)
341 rhsResult = rhs->isNotOrInvolved();
343 if (NULL != lhs)
345 //Means it involves only Logical operator
346 switch(logicalOp)
348 case OpAnd:
349 if (lhsResult || rhsResult) return true; else return false;
350 break;
351 case OpOr:
352 return true;
353 break;
354 case OpNot:
355 default:
356 return true;
357 break;
360 return false;
363 void* PredicateImpl::getValIfPointLookupOnInt(int &offset)
364 { //perf opt
365 if (NULL != lhs && NULL != rhs) return NULL;
366 if(typeInt != type || comp2Op !=OpInvalidComparisionOp) return NULL;
367 if (compOp != OpEquals) return NULL;
368 offset = offset1;
369 void *val =NULL;
370 if(operand == NULL && operandPtr != NULL)
372 val = *(void**)operandPtr;
373 } else if(operand != NULL && operandPtr == NULL)
375 val = (void*) operand;
377 return val;
380 void* PredicateImpl::getVal1IfBetweenOnInt(int &offset)
381 { //perf opt
382 if (NULL != lhs && NULL != rhs) return NULL;
383 if(typeInt != type) return NULL;
384 if (compOp != OpGreaterThanEquals ||
385 comp2Op !=OpLessThanEquals) return NULL;
386 offset = offset1;
387 void *val =NULL;
388 if(operand == NULL && operandPtr != NULL)
390 val = *(void**)operandPtr;
391 } else if(operand != NULL && operandPtr == NULL)
393 val = (void*) operand;
395 return val;
398 void* PredicateImpl::getVal2IfBetweenOnInt(int &offset)
399 { //perf opt
400 if (NULL != lhs && NULL != rhs) return NULL;
401 if(typeInt != type) return NULL;
402 if (compOp != OpGreaterThanEquals ||
403 comp2Op !=OpLessThanEquals) return NULL;
404 offset = offset1;
405 void *val =NULL;
406 if(operand2 == NULL && operand2Ptr != NULL)
408 val = *(void**)operand2Ptr;
409 } else if(operand2 != NULL && operand2Ptr == NULL)
411 val = (void*) operand2;
413 return val;
416 void PredicateImpl::solveForProjList(Table *tab)
418 if (NULL != lhs)
420 lhs->solveForProjList(tab);
422 if (NULL != rhs)
424 rhs->solveForProjList(tab);
426 table = tab;
427 if (NULL != lhs) return ;
428 bool isExist1=false;
429 bool isExist2=false;
430 if (projList)
432 ListIterator fIter = projList->getIterator();
433 JoinProjFieldInfo *def;
434 while (fIter.hasElement())
436 def = (JoinProjFieldInfo*) fIter.nextElement();
437 if (!isExist1 && 0 == strcmp(fldName1, def->tabFieldName))
439 isExist1=true;
441 if (!isExist2 && 0 == strcmp(fldName2, def->tabFieldName) )
443 isExist2=true;
446 if (!isExist1)
448 tab->bindFld(fldName1, NULL);
450 if (!isExist2 && strcmp(fldName2, "")!=0)
452 tab->bindFld(fldName2, NULL);
457 void PredicateImpl::setOffsetAndType()
459 if (NULL != lhs)
461 lhs->setOffsetAndType();
463 if (NULL != rhs)
465 rhs->setOffsetAndType();
467 char fieldName1[IDENTIFIER_LENGTH];
468 char fieldName2[IDENTIFIER_LENGTH];
469 memset(fieldName1, 0, IDENTIFIER_LENGTH);
470 memset(fieldName2, 0, IDENTIFIER_LENGTH);
471 Table::getFieldNameAlone(fldName1, fieldName1);
472 Table::getFieldNameAlone(fldName2, fieldName2);
473 //this function is called only from TableImpl
474 TableImpl *tImpl = (TableImpl*) table;
475 if(fieldName1){
476 FieldInfo *info = new FieldInfo();
477 tImpl->getFieldInfo(fieldName1, info);
478 offset1 = tImpl->getFieldOffset(fieldName1);
479 fldPos = tImpl->getFldPos(fieldName1);
480 type = info->type;
481 length = info->length;
482 isNullable = true;
483 if (info->isNull || info->isPrimary || info->isAutoIncrement)
484 isNullable = false;
485 //printf("isNullable is set to %d\n", isNullable);
486 delete info;
489 if(fieldName2){
490 offset2 = tImpl->getFieldOffset(fieldName2);
491 if(typeUnknown == type)
492 type = tImpl->getFieldType(fieldName2);
497 bool PredicateImpl::pointLookupInvolved(const char *fname)
499 bool rhsResult, lhsResult;
500 if (NULL != lhs)
502 lhsResult = lhs->pointLookupInvolved(fname);
504 if (NULL != rhs)
506 rhsResult = rhs->pointLookupInvolved(fname);
508 if (NULL != lhs)
510 //Means it involves only Logical operator
511 switch(logicalOp)
513 case OpAnd:
514 //return lhsResult;
515 if (lhsResult || rhsResult) return true; else return false;
516 break;
517 case OpOr:
518 return false;
519 break;
520 case OpNot:
521 default:
522 return false;
523 break;
526 //Means it is relational expression
527 //first operand is always field identifier
528 char fieldName1[IDENTIFIER_LENGTH];
529 Table::getFieldNameAlone(fldName1, fieldName1);
530 if (OpEquals == compOp)
532 //for expressions f1 == f2 use full scan, so return false
533 if(NULL == operand && NULL == operandPtr) return false;
534 if(0 == strcmp(fieldName1, fname))
536 return true;
539 return false;
542 bool PredicateImpl::isBetweenInvolved(const char *fname)
544 bool rhsResult, lhsResult;
545 if (NULL != lhs)
547 lhsResult = lhs->isBetweenInvolved(fname);
549 if (NULL != rhs)
551 rhsResult = rhs->isBetweenInvolved(fname);
553 if (NULL != lhs)
555 switch(logicalOp)
557 case OpAnd:
558 if (lhsResult && rhsResult) return true; else return false;
559 break;
560 default:
561 return false;
562 break;
565 char fieldName1[IDENTIFIER_LENGTH];
566 Table::getFieldNameAlone(fldName1, fieldName1);
567 if ( OpGreaterThan == compOp || OpGreaterThanEquals == compOp)
569 if(0 == strcmp(fieldName1, fname))
571 return true;
574 return false;
577 bool PredicateImpl::rangeQueryInvolved(const char *fname)
579 bool rhsResult, lhsResult;
580 if (NULL != lhs)
582 lhsResult = lhs->rangeQueryInvolved(fname);
584 if (NULL != rhs)
586 rhsResult = rhs->rangeQueryInvolved(fname);
588 if (NULL != lhs)
590 switch(logicalOp)
592 case OpAnd:
593 if (lhsResult || rhsResult) return true; else return false;
594 break;
595 case OpOr:
596 return false;
597 break;
598 case OpNot:
599 default:
600 return false;
601 break;
604 //Means it is relational expression
605 //first operand is always field identifier
606 char fieldName1[IDENTIFIER_LENGTH];
607 Table::getFieldNameAlone(fldName1, fieldName1);
608 if (OpLessThan == compOp || OpLessThanEquals == compOp ||
609 OpGreaterThan == compOp || OpGreaterThanEquals == compOp)
611 //for expressions f1 == f2 use full scan, so return false
612 if(NULL == operand && NULL == operandPtr) return false;
613 if(0 == strcmp(fieldName1, fname))
615 return true;
618 return false;
621 void* PredicateImpl::opAndValPtrForIndexField(const char *fname, bool isUnique,ComparisionOp &op)
623 ComparisionOp lhsOp= OpInvalidComparisionOp, rhsOp= OpInvalidComparisionOp;
624 void *lhsRet=NULL, *rhsRet=NULL;
625 if (NULL != lhs)
627 lhsRet = lhs->opAndValPtrForIndexField(fname, isUnique, lhsOp);
629 if (NULL != rhs)
631 rhsRet = rhs->opAndValPtrForIndexField(fname, isUnique,rhsOp);
633 if (lhsRet && lhsOp == OpEquals) { op = lhsOp; return lhsRet;}
634 if (rhsRet && rhsOp == OpEquals) { op = rhsOp; return rhsRet;}
635 if (NULL != lhs)
637 if( lhsRet) { op = lhsOp; return lhsRet; }
638 if( rhsRet) { op = rhsOp; return rhsRet; }
640 char fieldName1[IDENTIFIER_LENGTH];
641 Table::getFieldNameAlone(fldName1, fieldName1);
642 //Means it is relational expression
643 //first operand is always field identifier
644 if(0 == strcmp(fieldName1, fname))
646 op = compOp;
647 if (isUnique && compOp != OpLessThan &&
648 compOp != OpLessThanEquals &&
649 compOp != OpNotEquals ) isPushedDown = true;
650 if (operand) return operand; else return *(void**)operandPtr;
652 op = OpInvalidComparisionOp;
653 return NULL;
657 //called only in case of hash index scan
658 void* PredicateImpl::valPtrForIndexField(const char *fname, bool isUnique)
660 void *lhsRet=NULL, *rhsRet=NULL;
661 if (NULL != lhs)
663 lhsRet = lhs->valPtrForIndexField(fname, isUnique);
664 if ( lhsRet != NULL) return lhsRet;
666 if (NULL != rhs)
668 rhsRet = rhs->valPtrForIndexField(fname, isUnique);
669 if ( rhsRet != NULL) return rhsRet;
671 char fieldName1[IDENTIFIER_LENGTH];
672 Table::getFieldNameAlone(fldName1, fieldName1);
673 //Means it is relational expression
674 //first operand is always field identifier
675 if (OpEquals == compOp)
677 if(0 == strcmp(fieldName1, fname))
679 if (isUnique) isPushedDown = true;
680 if (operand) return operand; else return *(void**)operandPtr;
683 return NULL;
686 ComparisionOp PredicateImpl::opForIndexField(const char *fname)
688 ComparisionOp lhsRet= OpInvalidComparisionOp, rhsRet= OpInvalidComparisionOp;
689 if (NULL != lhs)
691 lhsRet = lhs->opForIndexField(fname);
692 if ( lhsRet != OpInvalidComparisionOp) return lhsRet;
695 if (NULL != rhs)
697 rhsRet = rhs->opForIndexField(fname);
698 if ( rhsRet != OpInvalidComparisionOp) return rhsRet;
700 char fieldName1[IDENTIFIER_LENGTH];
701 Table::getFieldNameAlone(fldName1, fieldName1);
702 if(0 == strcmp(fieldName1, fname))
704 return compOp;
706 return OpInvalidComparisionOp;
709 PredicateImpl* PredicateImpl::getTablePredicate()
711 PredicateImpl *lhsRet = NULL, *rhsRet = NULL;
712 if (NULL != lhs)
714 lhsRet = lhs->getTablePredicate();
715 if ( lhsRet != NULL) return lhsRet;
717 if (NULL != rhs)
719 rhsRet = rhs->getTablePredicate();
720 if ( rhsRet != NULL) return rhsRet;
722 if (operand || operandPtr )
724 //printf("PRABA::getTablePredicate returning %s %d\n", fldName1, compOp);
725 if (parent)
727 if (this == parent->lhs) {
728 parent->lhs = NULL;
730 else {
731 parent->rhs = NULL;
733 parent = NULL;
735 return this;
737 return NULL;
740 PredicateImpl* PredicateImpl::getJoinPredicate()
742 PredicateImpl *lhsRet = NULL, *rhsRet = NULL;
743 if (NULL != lhs)
745 lhsRet = lhs->getJoinPredicate();
746 if ( lhsRet != NULL) return lhsRet;
748 if (NULL != rhs)
750 rhsRet = rhs->getJoinPredicate();
751 if ( rhsRet != NULL) return rhsRet;
753 if (0 != strcmp(fldName2, ""))
755 //printf("PRABA::getJoinPredicate returning %s %s\n", fldName1, fldName2);
756 if (parent)
758 if (this == parent->lhs)
759 parent->lhs = NULL;
760 else
761 parent->rhs = NULL;
762 parent = NULL;
764 return this;
766 return NULL;
769 void PredicateImpl::removeIfNotNecessary()
771 if (NULL != lhs)
773 lhs->removeIfNotNecessary();
775 if (NULL != rhs)
777 rhs->removeIfNotNecessary();
779 if (logicalOp != OpAnd) return;
780 if (NULL == lhs && NULL == rhs)
782 if (NULL == parent)
784 return;
786 if (this == parent->rhs) parent->rhs = NULL;
787 else if (this == parent->lhs) parent->lhs = NULL;
788 //TODO::PRABA::fix the leak below. if uncommented dumps core
789 //delete this;
790 //WARNINGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
791 //current object is deleted. do not any code here
792 return;
794 else if (NULL == lhs )
796 //left side of the node is empty means we can remove this AND node
797 //and place it as left or right of my parent where i am currently placed
798 if (NULL == parent)
800 return;
802 if (this == parent->rhs) parent->rhs=this->rhs;
803 else if (this == parent->lhs) parent->lhs = this->rhs;
804 //TODO::PRABA::fix the leak below. if uncommented dumps core
805 //delete this;
806 //WARNINGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
807 //current object is deleted. do not any code here
808 return;
810 else if (NULL == rhs )
812 //right side of the node is empty means we can remove this AND node
813 //and place it as left or right of my parent where i am currently placed
814 if (NULL == parent)
816 return;
818 if (this == parent->rhs) parent->rhs=this->lhs;
819 else if (this == parent->lhs) parent->lhs = this->lhs;
820 //TODO::PRABA::fix the leak below. if uncommented dumps core
821 //delete this;
822 //WARNINGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
823 //current object is deleted. do not any code here
824 return;
826 return;
829 bool PredicateImpl::isDummyPredicate()
831 if (NULL == lhs && NULL == rhs && NULL == parent
832 && NULL == operand && NULL == operandPtr &&
833 (0 == strcmp(fldName1, "")) && (0==strcmp(fldName2, "")))
834 return true;
835 else
836 return false;
839 PredicateImpl* PredicateImpl::getIfOneSidedPredicate()
841 if (logicalOp != OpAnd) return NULL;
842 if (NULL == lhs && NULL !=rhs)
844 return rhs;
846 if (NULL != lhs && NULL ==rhs)
848 return lhs;
850 return NULL;