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 1nWFP1-0002cX-2t for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Mar 2022 10:36:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nWFOz-0002UP-Ke for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Mar 2022 10:36:41 +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 1nWFOz-0002UF-B9 for pgsql-hackers@lists.postgresql.org; Mon, 21 Mar 2022 10:36:41 +0000 Received: from mail1.dalibo.net ([212.83.143.11] helo=mail.dalibo.com) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nWFOx-0001vB-41 for pgsql-hackers@postgresql.org; Mon, 21 Mar 2022 10:36:40 +0000 Received: from karst (larco.ioguix.net [78.202.0.6]) by mail.dalibo.com (Postfix) with ESMTPSA id ADBB51F9CF; Mon, 21 Mar 2022 11:36:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1647858995; bh=XrOpVzWXwhnk+CgvmeTpeJM1WOJ2up+tXHPdHzqemyo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AoF8oG360gOt0iHUsfmNUohmiO7uGzhXutdFi8ln0dz2ExCJftQHmivQ8wQediut7 QTu5iZFOnWLMVz0r2FwgQrk0MFd+PhmM2PAjGOxyk585qkhYIL7MAYJyJTAGhuvv3H avx0islUFap+1nrjZyzbPfLithaQy1WShcZP2kIw= Date: Mon, 21 Mar 2022 11:36:34 +0100 From: Jehan-Guillaume de Rorthais To: Arne Roland Cc: Christophe Courtois , pgsql-hackers Subject: Re: Detaching a partition with a FK on itself is not possible Message-ID: <20220321113634.68c09d4b@karst> In-Reply-To: <666ad9554f9d4781aa45c4613544075d@index.de> References: <06c75996-f72b-e57b-0efe-31e74a475c39@dalibo.com> <666ad9554f9d4781aa45c4613544075d@index.de> Organization: Dalibo MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Thu, 17 Mar 2022 17:58:04 +0000 Arne Roland wrote: > I don't think this a bug, but a feature request. I therefore think hackers > would be more appropriate. +1 I changed the list destination > I don't see how an additional syntax to modify the constraint should help. Me neiher. > If I'd want to fix this, I'd try to teach the detach partition code about > self referencing foreign keys. It seems to me like that would be the cleanest > solution, because the user doesn't need to care about this at all. Teaching the detach partition about self referencing means either: * it's safe to remove the FK * we can rewrite the FK for self referencing Both solution are not ideal from the original schema and user perspective. Another solution could be to teach the create partition to detect a self referencing FK and actually create a self referencing FK, not pointing to the partitioned table, and of course issuing a NOTICE to the client.