/ Check that this filter is a good join filter. */ If so the opj block will be set accordingly. */ opj points to the join block, fprec to the filter block to which */ the rest of the chain must be linked in case of success. */ teq, tek and tk2 indicates the severity of the tests: */ tk2 == TRUE means both columns must be primary k
| 535 | /* thx == TRUE means at least one column must be a leading index key. */ |
| 536 | /***********************************************************************/ |
| 537 | bool FILTER::FindJoinFilter(POPJOIN opj, PFIL fprec, bool teq, bool tek, |
| 538 | bool tk2, bool tc2, bool tix, bool thx) |
| 539 | { |
| 540 | if (trace(1)) |
| 541 | htrc("FindJoinFilter: opj=%p fprec=%p tests=(%d,%d,%d,%d)\n", |
| 542 | opj, fprec, teq, tek, tk2, tc2); |
| 543 | |
| 544 | // Firstly check that this filter is an independent filter |
| 545 | // meaning that it is the only one in its own group. |
| 546 | if (Next && Next->Opc != OP_SEP) |
| 547 | return (Opc < 0); |
| 548 | |
| 549 | // Keep only equi-joins and specific joins (Outer and Distinct) |
| 550 | // Normally specific join operators come first because they have |
| 551 | // been placed first by SortJoin. |
| 552 | if (teq && Opc > OP_EQ) |
| 553 | return FALSE; |
| 554 | |
| 555 | // We have a candidate for join filter, now check that it |
| 556 | // fulfil the requirement about its operands, to point to |
| 557 | // columns of respectively the two TDB's of that join. |
| 558 | int col1 = 0, col2 = 0; |
| 559 | bool key = tk2; |
| 560 | bool idx = FALSE, ihx = FALSE; |
| 561 | PIXDEF pdx; |
| 562 | |
| 563 | for (int i = 0; i < 2; i++) |
| 564 | if (GetArgType(i) == TYPE_COLBLK) { |
| 565 | PCOL colp = (PCOL)Arg(i); |
| 566 | |
| 567 | if (tk2) |
| 568 | key &= (colp->IsKey()); |
| 569 | else |
| 570 | key |= (colp->IsKey()); |
| 571 | |
| 572 | pdx = ((PTDBASE)colp->GetTo_Tdb())->GetColIndex(colp); |
| 573 | idx |= (pdx && pdx->GetNparts() == 1); |
| 574 | ihx |= (pdx != NULL); |
| 575 | |
| 576 | if (colp->VerifyColumn(opj->GetTbx1())) |
| 577 | col1 = i + 1; |
| 578 | else if (colp->VerifyColumn(opj->GetTbx2())) |
| 579 | col2 = i + 1; |
| 580 | |
| 581 | } else if (!tc2 && GetArgType(i) != TYPE_CONST) { |
| 582 | PXOB xp = Arg(i); |
| 583 | |
| 584 | if (xp->VerifyColumn(opj->GetTbx1())) |
| 585 | col1 = i + 1; |
| 586 | else if (xp->VerifyColumn(opj->GetTbx2())) |
| 587 | col2 = i + 1; |
| 588 | |
| 589 | } else |
| 590 | return (Opc < 0); |
| 591 | |
| 592 | if (col1 == 0 || col2 == 0) |
| 593 | return (Opc < 0); |
| 594 |
nothing calls this directly
no test coverage detected