Re: ALTER TABLE .. DETACH PARTITION CONCURRENTLY

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Amit Langote <amitlangote09(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: ALTER TABLE .. DETACH PARTITION CONCURRENTLY
Date: 2021-03-19 13:57:37
Message-ID: 20210319135737.GA28771@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021-Mar-17, Justin Pryzby wrote:

> The v8 patch has the "broken constraint" problem.

Yeah, I had misunderstood what the problem was. I think a good solution
to this is to have get_partition_parent return the true parent even when
a detach is pending, for one particular callsite. (This means adjusting
all other callsites.) Notpatch attached (applies on top of v8).

> Also, it "fails to avoid" adding duplicate constraints:
>
> Check constraints:
> "c" CHECK (i IS NOT NULL AND i > 1 AND i < 2)
> "cc" CHECK (i IS NOT NULL AND i >= 1 AND i < 2)
> "p1_check" CHECK (true)
> "p1_i_check" CHECK (i IS NOT NULL AND i >= 1 AND i < 2)

Do you mean the "cc" and "p1_i_check" one? I mean, if you already have
a constraint in the partition that duplicates the partition constraint,
then during attach we still create our new constraint? I guess a
solution to this would be to scan all constraints and see if any equals
the expression that the new one would have. Sounds easy enough now that
write it out loud.

Thanks

--
Álvaro Herrera 39°49'30"S 73°17'W
"Java is clearly an example of money oriented programming" (A. Stepanov)

Attachment Content-Type Size
0001-Fix-for-generation-of-invalid-constraints.notpatch text/plain 7.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-03-19 14:00:14 Re: Allow an alias to be attached directly to a JOIN ... USING
Previous Message David Steele 2021-03-19 13:55:29 Re: fdatasync performance problem with large number of DB files