Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j2GyK-00056f-1U for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2020 16:04:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j2GyH-0001Rf-G0 for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2020 16:04:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j2GyH-0001RY-7L for pgsql-hackers@lists.postgresql.org; Thu, 13 Feb 2020 16:04:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j2GyE-0006Yj-VC for pgsql-hackers@postgresql.org; Thu, 13 Feb 2020 16:04:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 01DG43Dr027105; Thu, 13 Feb 2020 11:04:03 -0500 From: Tom Lane To: Amit Langote cc: Justin Pryzby , Alvaro Herrera , PostgreSQL-development Subject: Re: assert pg_class.relnatts is consistent In-reply-to: References: <20200212182337.GZ1412@telsasoft.com> Comments: In-reply-to Amit Langote message dated "Thu, 13 Feb 2020 17:12:48 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27103.1581609843.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 13 Feb 2020 11:04:03 -0500 Message-ID: <27104.1581609843@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Amit Langote writes: > On Thu, Feb 13, 2020 at 4:51 PM Amit Langote w= rote: >> 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 failin= g 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. (While we're at it, an awful lot of the bulk of pg_class.dat could be replaced by BKI_DEFAULT() entries in pg_class.h, though I'm less sure that that's much of an improvement. I think we intentionally didn't bother when we put in the BKI_DEFAULT support, reasoning that there were too few pg_class.dat entries to bother.) regards, tom lane