Fix initdb's unsafe not-null-marking rule

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

From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Date: 2020-07-19T18:03:20Z
Lists: pgsql-hackers

Attachments

Part of the blame for the pg_subscription.subslotname fiasco can be laid
at the feet of initdb's default rule for marking columns NOT NULL; that
rule is fairly arbitrary and does not guarantee to make safe choices.
I propose that we change it so that it *is* safe, ie it will only mark
fields NOT NULL if they'd certainly be safe to access as C struct fields.

Keeping the end results the same requires a few more manual applications
of BKI_FORCE_NOT_NULL than we had before.  But I think that that's fine,
because it reduces the amount of poorly-documented magic in this area.
I note in particular that bki.sgml was entirely failing to tell the full
truth.

(Note: this would allow reverting the manual BKI_FORCE_NULL label that
I just added to pg_subscription.subslotname, but I feel no great desire
to do that.)

I propose this only for HEAD, not the back branches.

			regards, tom lane

Commits

  1. Be more careful about marking catalog columns NOT NULL by default.