Surely this code in setrefs.c is wrong?

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2023-09-09T23:22:52Z
Lists: pgsql-hackers
I happened to notice this bit in fix_expr_common's processing
of ScalarArrayOpExprs:

        set_sa_opfuncid(saop);
        record_plan_function_dependency(root, saop->opfuncid);

        if (!OidIsValid(saop->hashfuncid))
            record_plan_function_dependency(root, saop->hashfuncid);

        if (!OidIsValid(saop->negfuncid))
            record_plan_function_dependency(root, saop->negfuncid);

Surely those if-conditions are exactly backward, and we should be
recording nonzero hashfuncid and negfuncid entries, not zero ones.
As-is, the code's a no-op because record_plan_function_dependency
will ignore OIDs less than FirstUnpinnedObjectId, including zero.

"git blame" blames 50e17ad28 and 29f45e299 for these, so v14
has only half the problem of later branches.

			regards, tom lane



Commits

  1. Fix incorrect logic in plan dependency recording