Re: ALTER CONSTRAINT on a partitioned FK isn't working

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, Ron <ronljohnsonjr(at)gmail(dot)com>
Subject: Re: ALTER CONSTRAINT on a partitioned FK isn't working
Date: 2021-05-04 16:26:53
Message-ID: 20210504162653.GA27100@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2021-May-03, Alvaro Herrera wrote:

> There is a case where it doesn't seem like we can easily give
> non-surprising behavior: when multi-level partitioning is used, a
> constraint is defined in the top level and then it is altered in the
> middle level, then we don't have access to the action triggers, because
> those are defined at the parent level. I opted for adding a WARNING
> message in that case. Other options were 1) to raise an error if
> altering a constraint that's not top level, but I fear that might break
> restoring dumps of existing database;

Actually, I tested this and it turns out to be a nonexistant problem: if
you alter a constraint that's not top-level, then pg_dump silently omits
the deferrability change there. So we can just have this emit ERROR and
nothing that works today would break. Users *would* get an error, but
then the alteration would not have the desired effect anyway. I suppose
we would have already got complaints if anybody were trying. (The error
message could stand some wording improvement ...)

So the attached version does that and I intend to get it pushed to all
branches (since 11) this afternoon unless I get any objections.

I'm CC'ing Ron as the reporter of the original bug.

--
Álvaro Herrera Valdivia, Chile

Attachment Content-Type Size
constraints.patch text/x-diff 17.8 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Manvendra 2021-05-04 16:35:06 NULL handling in 1D array comparison
Previous Message Santosh Udupi 2021-05-04 15:08:13 Re: pg_restore - generated column - not populating