Fix incorrect logic in plan dependency recording
authorDavid Rowley <[email protected]>
Wed, 13 Sep 2023 23:27:43 +0000 (11:27 +1200)
committerDavid Rowley <[email protected]>
Wed, 13 Sep 2023 23:27:43 +0000 (11:27 +1200)
Both 50e17ad28 and 29f45e299 mistakenly tried to record a plan dependency
on a function but mistakenly inverted the OidIsValid test.  This meant
that we'd record a dependency only when the function's Oid was
InvalidOid.  Clearly this was meant to *not* record the dependency in
that case.

50e17ad28 made this mistake first, then in v15 29f45e299 copied the same
mistake.

Reported-by: Tom Lane
Backpatch-through: 14, where 50e17ad28 first made this mistake
Discussion: https://postgr.es/m/2277537.1694301772@sss.pgh.pa.us

src/backend/optimizer/plan/setrefs.c

index 60e5a7280a2d3324a4739dae0b46919e12482462..7c6e2037656bb1ab23f6c7dbac4d4940a2e641b2 100644 (file)
@@ -1775,7 +1775,7 @@ fix_expr_common(PlannerInfo *root, Node *node)
        set_sa_opfuncid(saop);
        record_plan_function_dependency(root, saop->opfuncid);
 
-       if (!OidIsValid(saop->hashfuncid))
+       if (OidIsValid(saop->hashfuncid))
            record_plan_function_dependency(root, saop->hashfuncid);
    }
    else if (IsA(node, Const))