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

Method makeInferenceNode

src/jrd/optimizer/Optimizer.cpp:3367–3404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3365//
3366
3367BoolExprNode* Optimizer::makeInferenceNode(BoolExprNode* boolean,
3368 ValueExprNode* arg1,
3369 ValueExprNode* arg2)
3370{
3371 const auto cmpNode = nodeAs<ComparativeBoolNode>(boolean);
3372 fb_assert(cmpNode); // see our caller
3373
3374 // Clone the input predicate
3375 const auto newCmpNode =
3376 FB_NEW_POOL(getPool()) ComparativeBoolNode(getPool(), cmpNode->blrOp);
3377
3378 // We may safely copy invariantness flag because
3379 // (1) we only distribute field equalities
3380 // (2) invariantness of second argument of STARTING WITH or LIKE is solely
3381 // determined by its dependency on any of the fields
3382 // If provisions above change the line below will have to be modified
3383 newCmpNode->nodFlags = cmpNode->nodFlags;
3384
3385 // Share impure area for cached invariant value used to hold pre-compiled
3386 // pattern for new LIKE and CONTAINING algorithms.
3387 // Cached pattern matcher also should be shared by both nodes, else new node
3388 // could overwrite impure area at offset zero. See bug GH-7276.
3389 // Proper cloning of impure area for this node would require careful accounting
3390 // of new invariant dependencies - we avoid such hassles via using single
3391 // cached pattern value for all node clones. This is faster too.
3392 if (newCmpNode->nodFlags & (ExprNode::FLAG_INVARIANT | ExprNode::FLAG_PATTERN_MATCHER_CACHE))
3393 newCmpNode->impureOffset = cmpNode->impureOffset;
3394
3395 // But substitute new values for some of the predicate arguments
3396 newCmpNode->arg1 = CMP_clone_node_opt(tdbb, csb, arg1);
3397 newCmpNode->arg2 = CMP_clone_node_opt(tdbb, csb, arg2);
3398
3399 // Arguments after the first two are just cloned (eg: LIKE ESCAPE clause)
3400 if (cmpNode->arg3)
3401 newCmpNode->arg3 = CMP_clone_node_opt(tdbb, csb, cmpNode->arg3);
3402
3403 return newCmpNode;
3404}
3405
3406
3407BoolExprNode* Optimizer::makeInferenceNode(BoolExprNode* boolean,

Callers

nothing calls this directly

Calls 5

CMP_clone_node_optFunction · 0.85
InListBoolNodeClass · 0.85
ComparativeBoolNodeClass · 0.70
copyMethod · 0.45
pass2Method · 0.45

Tested by

no test coverage detected