Re: Recording foreign key relationships for the system catalogs

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

From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Joel Jacobson" <joel@compiler.org>
Cc: pgsql-hackers@lists.postgresql.org, "Peter Eisentraut" <peter.eisentraut@enterprisedb.com>
Date: 2021-02-02T03:27:42Z
Lists: pgsql-hackers

Attachments

"Joel Jacobson" <joel@compiler.org> writes:
> Could it be an idea to also add
>    OUT can_be_zero boolean
> to pg_get_catalog_foreign_keys()'s out parameters?

I was initially feeling resistant to that idea, but warmed to it
once I realized that a majority of the FK referencing columns
actually should not contain zeroes.  So we can get a useful
improvement in the strictness of the test coverage if we make this
distinction --- and we can enforce it in the initial catalog data,
too.

So here's a v2 that does that.  In the interests of brevity,
I spelled the declaration macros that allow a zero as BKI_LOOKUP_OPT,
DECLARE_FOREIGN_KEY_OPT, etc; and thus the output column is
also is_opt.  I'm not wedded to that term but I think we need
something pretty short.

This also moves the oidjoins regression test to run near the
end of the test suite.  As I commented earlier, that test was
originally mainly meant to validate the handwritten initial
data; but nowadays it's hard to see what it would catch that
genbki.pl doesn't.  So the usefulness is in looking at rows
that get added later, and therefore we ought to run it after
the regression tests have created stuff.  I've tried here
to run it in parallel with event_triggers, which might be
foolish.

I also added some documentation.  I feel like this might
be committable at this point.

			regards, tom lane

Commits

  1. Remove special BKI_LOOKUP magic for namespace and role OIDs.

  2. Retire findoidjoins.

  3. Build in some knowledge about foreign-key relationships in the catalogs.