Re: Can not drop partition if exist foreign keys

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Олег Самойлов <splarv(at)ya(dot)ru>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Can not drop partition if exist foreign keys
Date: 2023-10-11 11:17:57
Message-ID: 202310111117.cdj4ngpfrppg@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2023-10-11 11:20:29 Re: Can not drop partition if exist foreign keys
Previous Message Олег Самойлов 2023-10-11 11:08:54 Can not drop partition if exist foreign keys