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 1oQYCS-0006HB-UW for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Aug 2022 18:00:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oQYCR-00025Y-Pt for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Aug 2022 18:00:27 +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 1oQYCR-00025P-HD for pgsql-hackers@lists.postgresql.org; Tue, 23 Aug 2022 18:00:27 +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 1oQYCP-00089h-D1 for pgsql-hackers@postgresql.org; Tue, 23 Aug 2022 18:00:26 +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 27NI0D21731874; Tue, 23 Aug 2022 14:00:13 -0400 From: Tom Lane To: Alvaro Herrera cc: Jehan-Guillaume de Rorthais , pgsql-hackers Subject: Re: [BUG] parenting a PK constraint to a self-FK one (Was: Self FK oddity when attaching a partition) In-reply-to: <20220823163006.smdpovyl4dhcakvr@alvherre.pgsql> References: <20220823163006.smdpovyl4dhcakvr@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Tue, 23 Aug 2022 18:30:06 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <731872.1661277613.1@sss.pgh.pa.us> Date: Tue, 23 Aug 2022 14:00:13 -0400 Message-ID: <731873.1661277613@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera writes: > If this is OK, we should make this API quirkiness very explicit in the > comments, so the patch needs to be a few lines larger in order to be > committable. Also, perhaps the check should be that contype equals > either primary or unique, rather than it doesn't equal foreign. Yeah. See lsyscache.c's get_constraint_index(), as well as commit 641f3dffc which fixed a mighty similar-seeming bug. One question that precedent raises is whether to also include CONSTRAINT_EXCLUSION. But in any case a positive test for the constraint types to allow seems best. regards, tom lane