Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT

Поиск
Список
Период
Сортировка
Искать
От
Amit Langote
Тема
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT
Дата
Msg-id
24217a8f-5f9b-8bcc-1698-ff38921addee@lab.ntt.co.jp
Ответ на
Список
Дерево обсуждения
BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT PG Bug reporting form <noreply@postgresql.org>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Alvaro Herrera <alvherre@2ndquadrant.com>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Alvaro Herrera <alvherre@2ndquadrant.com>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Jesper Pedersen <jesper.pedersen@redhat.com>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Alvaro Herrera <alvherre@2ndquadrant.com>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Alvaro Herrera <alvherre@2ndquadrant.com>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Alvaro Herrera <alvherre@2ndquadrant.com>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Alvaro Herrera <alvherre@2ndquadrant.com>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Alvaro Herrera <alvherre@2ndquadrant.com>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Alvaro Herrera <alvherre@2ndquadrant.com>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Alvaro Herrera <alvherre@2ndquadrant.com>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT Jesper Pedersen <jesper.pedersen@redhat.com>
Hi,

On 2019/01/18 7:23, Alvaro Herrera wrote:
> On 2019-Jan-16, Amit Langote wrote:
> 
>> Why not just move the code in clone_fk_constraints() that checks if the
>> constraint equivalent of the parent's constraint is present in the
>> partition and simply attach the two without creating a new copy for the
>> partition to a new function in tablecmds.c and call the function from both
>> clone_fk_constraints() and ATAddForeignKeyConstraint()?  Attached is what
>> I'm thinking.
> 
> Well, the whole point of my proposal is that the FK-creating code
> recurses to partitions by calling ATAddForeignKeyConstraint, and IMO
> that's the wrong level to recurse at; we should instead recurse by
> calling clone_fk_constraints() as a whole.

Sorry about the noise.  I agree with the committed approach.  With this,
ALTER TABLE ADD FOREIGN KEY's inheritance recursion path now looks
completely different from ALTER TABLE ADD CHECK's, but that's fine.
Actually, if we had the same "clone" approach for check constraints, which
both checks if a child already has the constraint being cloned and creates
one if not, we could do away with errors like the following:

create table p (a int, constraint check_a check (a > 0)) partition by list
create table p1 (a int);
alter table p attach partition p1 for values in (1);
ERROR:  child table is missing constraint "check_a"

But of course that would be a different feature.

Thanks,
Amit


В списке pgsql-bugs по дате отправления
От: David Rowley
Дата:
От: Marcin Barczyński
Дата:
FAQ