/ Block optimization: evaluate the block index filter against */ the min and max values of this block and return: */ RC_OK: if some records in the block can meet filter criteria. */ RC_NF: if no record in the block can meet filter criteria. */ RC_EF: if no record in the remaining file can meet filter criteria.*/ In addition, temporarily suppress filtering if a
| 1623 | /* the block meet filter criteria. */ |
| 1624 | /***********************************************************************/ |
| 1625 | int TDBDOS::TestBlock(PGLOBAL g) |
| 1626 | { |
| 1627 | int rc = RC_OK; |
| 1628 | |
| 1629 | if (To_BlkFil && Beval != 2) { |
| 1630 | // Check for block filtering evaluation |
| 1631 | if (Beval == 1) { |
| 1632 | // Filter was removed for last block, restore it |
| 1633 | To_Filter = SavFil; |
| 1634 | SavFil = NULL; |
| 1635 | } // endif Beval |
| 1636 | |
| 1637 | // Check for valid records in new block |
| 1638 | switch (Beval = To_BlkFil->BlockEval(g)) { |
| 1639 | case -2: // No more valid values in file |
| 1640 | rc = RC_EF; |
| 1641 | break; |
| 1642 | case -1: // No valid values in block |
| 1643 | rc = RC_NF; |
| 1644 | break; |
| 1645 | case 1: // All block values are valid |
| 1646 | case 2: // All subsequent file values are Ok |
| 1647 | // Before suppressing the filter for the block(s) it is |
| 1648 | // necessary to reset the filtered columns to NOT_READ |
| 1649 | // so their new values are retrieved by the SELECT list. |
| 1650 | if (To_Filter) // Can be NULL when externally called (XDB) |
| 1651 | To_Filter->Reset(); |
| 1652 | |
| 1653 | SavFil = To_Filter; |
| 1654 | To_Filter = NULL; // So remove filter |
| 1655 | } // endswitch Beval |
| 1656 | |
| 1657 | if (trace(1)) |
| 1658 | htrc("BF Eval Beval=%d\n", Beval); |
| 1659 | |
| 1660 | } // endif To_BlkFil |
| 1661 | |
| 1662 | return rc; |
| 1663 | } // end of TestBlock |
| 1664 | |
| 1665 | /***********************************************************************/ |
| 1666 | /* Check whether we have to create/update permanent indexes. */ |
no test coverage detected