pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Олег Самойлов <splarv@ya.ru>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Can not drop partition if exist foreign keys
Date: Wed, 11 Oct 2023 13:17:57 +0200
Message-ID: <202310111117.cdj4ngpfrppg@alvherre.pgsql> (raw)
In-Reply-To: <5E197F1B-BDDF-40AF-9D87-D6792CE1A3B9@ya.ru>

On 2023-Oct-11, Олег Самойлов 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.

Yeah.  Detach it first, then you should be able to drop it.

> psql:test.sql:15: ERROR:  cannot drop table parent_0 because other objects depend on it
> DETAIL:  constraint children_id_fkey on table children depends on table parent_0
> HINT:  Use DROP ... CASCADE to drop the dependent objects too.
> 
> Looked like a bug.

We tried to make DROP work, but we didn't find a way.  Patches welcome.

-- 
Álvaro Herrera





view thread (5+ messages)  latest in thread

Message-ID: <202310111117.cdj4ngpfrppg@alvherre.pgsql>
Permalink:  ../202310111117.cdj4ngpfrppg@alvherre.pgsql/
Also on:    postgresql.org/message-id/202310111117.cdj4ngpfrppg@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: alvherre@alvh.no-ip.org, splarv@ya.ru
  Subject: Re: Can not drop partition if exist foreign keys
  In-Reply-To: <202310111117.cdj4ngpfrppg@alvherre.pgsql>
  References: <5E197F1B-BDDF-40AF-9D87-D6792CE1A3B9@ya.ru> <202310111117.cdj4ngpfrppg@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox