MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / matchBoolean

Method matchBoolean

src/jrd/optimizer/Retrieval.cpp:1689–2032  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1687}
1688
1689bool Retrieval::matchBoolean(IndexScratch* indexScratch,
1690 BoolExprNode* boolean,
1691 unsigned scope) const
1692{
1693 if (boolean->nodFlags & ExprNode::FLAG_DEOPTIMIZE)
1694 return false;
1695
1696 const auto cmpNode = nodeAs<ComparativeBoolNode>(boolean);
1697 const auto missingNode = nodeAs<MissingBoolNode>(boolean);
1698 const auto listNode = nodeAs<InListBoolNode>(boolean);
1699 const auto notNode = nodeAs<NotBoolNode>(boolean);
1700 const auto rseNode = nodeAs<RseBoolNode>(boolean);
1701 bool forward = true;
1702 ValueExprNode* value = nullptr;
1703 ValueExprNode* match = nullptr;
1704 ValueListNode* list = nullptr;
1705
1706 if (cmpNode)
1707 {
1708 match = cmpNode->arg1;
1709 value = cmpNode->arg2;
1710 }
1711 else if (listNode)
1712 {
1713 match = listNode->arg;
1714 list = listNode->list;
1715
1716 if (!list->computable(csb, stream, false))
1717 return false;
1718 }
1719 else if (missingNode)
1720 match = missingNode->arg;
1721 else
1722 {
1723 fb_assert(notNode || rseNode);
1724 return false;
1725 }
1726
1727 ValueExprNode* value2 = (cmpNode && cmpNode->blrOp == blr_between) ?
1728 cmpNode->arg3 : nullptr;
1729
1730 const auto idx = indexScratch->index;
1731
1732 if (idx->idx_flags & idx_condition)
1733 {
1734 // If index condition matches the boolean, this should not be
1735 // considered a match. Full index scan will be used instead.
1736 if (idx->idx_condition->sameAs(boolean, true))
1737 return false;
1738 }
1739
1740 if (idx->idx_flags & idx_expression)
1741 {
1742 // see if one side or the other is matchable to the index expression
1743
1744 if (!checkIndexExpression(idx, match) ||
1745 (value && !value->computable(csb, stream, false)))
1746 {

Callers

nothing calls this directly

Calls 8

BTR_types_comparableFunction · 0.85
invertBoolValueFunction · 0.85
swapFunction · 0.50
computableMethod · 0.45
sameAsMethod · 0.45
getDescMethod · 0.45
getCountMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected