Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sblej-001HGp-OZ for pgsql-bugs@arkaria.postgresql.org; Wed, 07 Aug 2024 18:45:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sblei-009Gzu-71 for pgsql-bugs@arkaria.postgresql.org; Wed, 07 Aug 2024 18:45:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sbleh-009Gyu-0v for pgsql-bugs@lists.postgresql.org; Wed, 07 Aug 2024 18:45:03 +0000 Received: from fhigh8-smtp.messagingengine.com ([103.168.172.159]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sblee-003aKf-Bf for pgsql-bugs@lists.postgresql.org; Wed, 07 Aug 2024 18:45:01 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id A941311511AF; Wed, 7 Aug 2024 14:44:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 07 Aug 2024 14:44:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1723056298; x= 1723142698; bh=F8J2KeyHKc9ye9w5WVnp8jlXDfjflFvFTlD0gyG7iso=; b=Z +VvJpbrgvH1K/L4ps6oWShF1WW7Sv0HL5HWyo57ICdD2pmVNxqP3/YRmM1XWyRwb E0VyDr/GLxDigCWFYBrgWUGp2ojZmzoCuavZ4V9rDRl3WdFEe8UZpfvaFylcD8r6 QE9gq+gaFfWu9HbfiHkdXBztggRvbLgB2g+p2mnRSZ8p0UNGX3XnUaJtr17uZZ9o ROGkqV9G98Fc0abHPQRM4BByuSJIbAbpJDVx6X04ZNvX2MZnjw1yiLXSbGtv+Hxj Vhcxsm0ErM+fxPhihf7fJ8256W4mkSxPfrYQ6c0vdfHU3TbHEEsUfHjyOiAp3LRv HDioeRlopNETwvlQ/Divw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrledtgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Aug 2024 14:44:58 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1723056295; bh=oDSE5ACZiICMDR/8OFZnqJpdv+DIL1PR7XMH+Z/zdQo=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=VUjmmkKNTQwT06kNHcULUCnN+6aP46LsW42deAhXmq/n3zA2WVEGTW6DmvRH6+2xL 6ijQEmaf7eoYO8DnWZsxeK7HVcXlKQxC8vJOwWp44/fw7aDp14EvYlOmNmW0XgCbAx K5w9vFllKUjy5MU5Ke+vXcVnsVpPgCyY+X/iQFu+EjbZYnFT9055z5DKoLFW2t0xuJ cE8psHuJbvs+rNjuMpwhoEYop+5vOQEhM9JHLDm01BEIpdNf0AJYlDbc2lRc6lqkxN fimZTe2kYh+p9kuCNv+lhyNCEiIezPMgAHmAgqbZpC2wXcYKYvNv0e7CJs5IOfB2eN hXSYVSEoPxE9w== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id B867414DB; Wed, 7 Aug 2024 20:44:55 +0200 (CEST) Date: Wed, 7 Aug 2024 14:44:55 -0400 From: Alvaro Herrera To: Tender Wang Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18541: Reattaching a partition referenced by a foreign key fails with an error Message-ID: <202408071844.d7mzelswgpdu@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Jul-15, Tender Wang wrote: > PG Bug reporting form 于2024年7月15日周一 21:02写道: > > > The following script: > > CREATE TABLE t1 (a int, PRIMARY KEY (a)); > > CREATE TABLE t (a int, PRIMARY KEY (a), FOREIGN KEY (a) REFERENCES t1) > > PARTITION BY LIST (a); > > ALTER TABLE t ATTACH PARTITION t1 FOR VALUES IN (1); > > ALTER TABLE t DETACH PARTITION t1; > > ALTER TABLE t ATTACH PARTITION t1 FOR VALUES IN (1); > > > > ends up with the error complaining about check triggers: > > ERROR: XX000: could not find ON INSERT check triggers of foreign key > > constraint 16400 > > LOCATION: GetForeignKeyCheckTriggers, tablecmds.c:11260 > I saw the same error in [1]. I guess it is same issue. > I send a patch in [1], but it may need a more work. I think this schema is nuts. Do you have a practical use for something like this? I am tempted to fix this by dictating that you can't join a table as a partition if the partitioned table contains an FK that references that table. FWIW the patch I have fixes all the other reported problems with FKs and partitioned tables, but not this one. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/