Re: Bug in detaching a partition with a foreign key.

Sami Imseih <samimseih@gmail.com>

From: Sami Imseih <samimseih@gmail.com>
To: Álvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Amul Sul <sulamul@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-01-20T18:26:13Z
Lists: pgsql-hackers
> > The patch that Amul and I wrote both achieve the same result.
> > The approach that Amul took builds a list of constraint OIDs,
> > which could grow with the number of partitions and foreign keys
> > on those partitions. Maybe not a big deal?

> Nope, not a big deal.  It would be a big deal if we were talking about
> 268 million partitions (>1GB palloc size), but that's impractical for
> other reasons.

that's fair.

Patch looks good to me, but I am not sure about this part of the comment:

"Only the topmost one is to be considered here; the child constraints
must be left alone,"

In this case, none of the pg_constraint entries are actually considered. right?

Regards,

Sami



Commits

  1. Fix detach of a partition that has a toplevel FK to a partitioned table