Re: assert pg_class.relnatts is consistent

Amit Langote <amitlangote09@gmail.com>

From: Amit Langote <amitlangote09@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Justin Pryzby <pryzby@telsasoft.com>, Alvaro Herrera <alvherre@2ndquadrant.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-02-14T05:58:37Z
Lists: pgsql-hackers
On Fri, Feb 14, 2020 at 1:04 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Amit Langote <amitlangote09@gmail.com> writes:
> > On Thu, Feb 13, 2020 at 4:51 PM Amit Langote <amitlangote09@gmail.com> wrote:
> >> I know I have made the mistake of not updating relnatts when I added
> >> relispartition, etc. to pg_class, only to be bitten by it in the form
> >> of seemingly random errors/crashes.  Is that why?
>
> > Sorry for not having read the patch properly.
> >> +     /* Check that pg_class data is consistent now, rather than failing obscurely later */
> > That seems to be it.
>
> I've been burnt by this too :-(.  However, I think this patch is
> completely the wrong way to go about improving this.  What we should
> be doing, now that we have all that perl code generating postgres.bki,
> is eliminating the problem at the source.  That is, drop the hand-coded
> relnatts values from pg_class.dat altogether, and let the perl code fill
> it in --- compare the handling of pg_proc.pronargs for instance.

I can't write Perl myself (maybe Justin), but +1 to this idea.

Thanks,
Amit



Commits

  1. Update obsolete comment.

  2. Clarify coding in Catalog::AddDefaultValues.

  3. Run "make reformat-dat-files".

  4. Don't require pg_class.dat to contain correct relnatts values.