MCPcopy Create free account
hub / github.com/apache/cloudberry / CachedPlanIsSimplyValid

Function CachedPlanIsSimplyValid

src/backend/utils/cache/plancache.c:1531–1568  ·  view source on GitHub ↗

* CachedPlanIsSimplyValid: quick check for plan still being valid * * This function must not be used unless CachedPlanAllowsSimpleValidityCheck * previously said it was OK. * * If the plan is valid, and "owner" is not NULL, record a refcount on * the plan in that resowner before returning. It is caller's responsibility * to be sure that a refcount is held on any plan that's being actively

Source from the content-addressed store, hash-verified

1529 * advisable to also save plan->generation and verify that that still matches.
1530 */
1531bool
1532CachedPlanIsSimplyValid(CachedPlanSource *plansource, CachedPlan *plan,
1533 ResourceOwner owner)
1534{
1535 /*
1536 * Careful here: since the caller doesn't necessarily hold a refcount on
1537 * the plan to start with, it's possible that "plan" is a dangling
1538 * pointer. Don't dereference it until we've verified that it still
1539 * matches the plansource's gplan (which is either valid or NULL).
1540 */
1541 Assert(plansource->magic == CACHEDPLANSOURCE_MAGIC);
1542
1543 /*
1544 * Has cache invalidation fired on this plan? We can check this right
1545 * away since there are no locks that we'd need to acquire first. Note
1546 * that here we *do* check plansource->is_valid, so as to force plan
1547 * rebuild if that's become false.
1548 */
1549 if (!plansource->is_valid || plan != plansource->gplan || !plan->is_valid)
1550 return false;
1551
1552 Assert(plan->magic == CACHEDPLAN_MAGIC);
1553
1554 /* Is the search_path still the same as when we made it? */
1555 Assert(plansource->search_path != NULL);
1556 if (!OverrideSearchPathMatchesCurrent(plansource->search_path))
1557 return false;
1558
1559 /* It's still good. Bump refcount if requested. */
1560 if (owner)
1561 {
1562 ResourceOwnerEnlargePlanCacheRefs(owner);
1563 plan->refcount++;
1564 ResourceOwnerRememberPlanCacheRef(owner, plan);
1565 }
1566
1567 return true;
1568}
1569
1570/*
1571 * CachedPlanSetParentContext: move a CachedPlanSource to a new memory context

Callers 1

exec_eval_simple_exprFunction · 0.85

Tested by

no test coverage detected