Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kPsgH-0000io-Ml for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Oct 2020 19:31:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kPsgE-0006dZ-TL for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Oct 2020 19:31:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kPsgE-0006dS-Mc for pgsql-hackers@lists.postgresql.org; Tue, 06 Oct 2020 19:31:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kPsgC-0001lp-K7 for pgsql-hackers@postgresql.org; Tue, 06 Oct 2020 19:31:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 096JVGqO1996233; Tue, 6 Oct 2020 15:31:16 -0400 From: Tom Lane To: Andres Freund cc: Peter Eisentraut , pgsql-hackers Subject: Re: Add primary keys to system catalogs In-reply-to: <20201006183450.f4jn7vzwsokqwgi2@alap3.anarazel.de> References: <20201006183450.f4jn7vzwsokqwgi2@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 06 Oct 2020 11:34:50 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1996231.1602012676.1@sss.pgh.pa.us> Date: Tue, 06 Oct 2020 15:31:16 -0400 Message-ID: <1996232.1602012676@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2020-10-03 08:40:31 +0200, Peter Eisentraut wrote: >> Since we have ADD PRIMARY KEY USING INDEX, we can declare a primary key for >> an existing index. So this doesn't have to affect the low-level early >> bootstrapping. The attached patch adds those commands manually. Another >> option might be to have the catalog generation Perl tooling create those >> declarations automatically from some marker in the catalog files. That >> would also allow declaring unique constraints for the unique indexes that >> don't end up being the primary key. > Hm. What prevents us from declaring the pkey during bootstrap? I don't > at all like adding yet another place that needs manual editing when > doing DDL changes. We don't add new catalogs often, so the cost-benefit ratio of automating this looks pretty poor. It's not like you'll be able to forget to do it, given the proposed regression test check for catalogs without pkeys. One thing I'm wondering about though is whether Peter's implementation ends up with desirable pg_depend contents for the pkey constraints. Probably we want them to just be pinned and not have any explicit dependencies on the associated indexes, but I haven't thought hard about it. regards, tom lane