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 1qqx6p-001qbP-1h for pgsql-general@arkaria.postgresql.org; Thu, 12 Oct 2023 14:56:19 +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 1qqx6l-0088st-Oh for pgsql-general@arkaria.postgresql.org; Thu, 12 Oct 2023 14:56:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qqx6l-0088s2-Cu for pgsql-general@lists.postgresql.org; Thu, 12 Oct 2023 14:56:16 +0000 Received: from forward501a.mail.yandex.net ([178.154.239.81]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qqx6i-000C56-5G for pgsql-general@lists.postgresql.org; Thu, 12 Oct 2023 14:56:15 +0000 Received: from mail-nwsmtp-mxback-production-main-93.vla.yp-c.yandex.net (mail-nwsmtp-mxback-production-main-93.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0f:784:0:640:dd76:0]) by forward501a.mail.yandex.net (Yandex) with ESMTP id B15666204A; Thu, 12 Oct 2023 17:56:10 +0300 (MSK) Received: from mail.yandex.ru (2a02:6b8:c15:2909:0:640:eee1:0 [2a02:6b8:c15:2909:0:640:eee1:0]) by mail-nwsmtp-mxback-production-main-93.vla.yp-c.yandex.net (mxback/Yandex) with HTTP id 7ugX7d6W7Ko0-ZuybOkB1; Thu, 12 Oct 2023 17:56:10 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ya.ru; s=mail; t=1697122570; bh=dz6Dx6jNC9BRrowK8usOKSpCj3RrEy3Y1XZ1fV1KngI=; h=Message-Id:References:Date:Subject:In-Reply-To:To:From; b=G5sxzCUO83ZcN+2LiD06kr5+g6qN/oOk5Kmk5QtGSPAtdKj30H+wr3VtvJggcN48X hr8RaBYfMSzxvLUe499EjbMUNvei5T69uf/LZX3MGCSwg0Yut7p/0ETEmrc/7D6LLN gdHcf+OPz0dse+v3+7Y33NWKPy8LyuBWIo6gsnlU= Authentication-Results: mail-nwsmtp-mxback-production-main-93.vla.yp-c.yandex.net; dkim=pass header.i=@ya.ru Received: by 6yorfbioao7cchjm.vla.yp-c.yandex.net with HTTP; Thu, 12 Oct 2023 17:56:10 +0300 From: =?utf-8?B?0J7Qu9C10LMg0KHQsNC80L7QudC70L7Qsg==?= Envelope-From: splarv@yandex.ru To: Laurenz Albe , pgsql-generallists.postgresql.org In-Reply-To: <4734b034a623e8fa9d7522e4b4b7995cd1f3728f.camel@cybertec.at> References: <5E197F1B-BDDF-40AF-9D87-D6792CE1A3B9@ya.ru> <4734b034a623e8fa9d7522e4b4b7995cd1f3728f.camel@cybertec.at> Subject: Re: Can not drop partition if exist foreign keys MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Thu, 12 Oct 2023 17:56:10 +0300 Message-Id: <1113211697122316@mail.yandex.ru> Content-Transfer-Encoding: 8bit Content-Type: text/html; charset=utf-8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk
 
 
11.10.2023, 14:20, "Laurenz Albe" <laurenz.albe@cybertec.at>:

On Wed, 2023-10-11 at 14:08 +0300, Олег Самойлов wrote:

 There are two common practice to drop partition from partitioned table: just drop or detach-drop.
 But simple drop don't work if exist foreign key. Example script attached.


That is working as designed. You cannot detach a partition of a table if a
foreign key points to it.

Nope, of cause any can detach a partition of a empty table even if a foreign key points to it.
The problem is other. Documented that there are two variants how drop partition. Just drop or detach then drop. Both work on a simple partition, but only the second variant works in this case.