how can we propagate fk constraints?

From: shrish purohit <shrishpurohit(at)gmail(dot)com>
To: Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Nikhil Sontakke <nikhil(dot)sontakke(at)enterprisedb(dot)com>, kedar(dot)potdar(at)gmail(dot)com, Amit Gupta <amit(dot)pc(dot)gupta(at)gmail(dot)com>
Subject: how can we propagate fk constraints?
Date: 2009-06-24 18:07:20
Message-ID: 69b219810906241107x5f6b6a36se666f78df1380182@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi All,

continued from discussion mail
http://archives.postgresql.org/pgsql-hackers/2009-06/msg00971.php

>
>
>> - Am I reading the patch correctly that you do not end up creating
>> indexes on the children tables? That is a big problem!
>
>
>
So what expected is when an index is created on Partitioned table it should
automatically create indexes on individual partitions with same attributes,
- name of the index on partition can be base index name appended with
tableoid,
- tablespace can be the same that of partition or tablespace specified in
create index statement.

Similarly we need to propagate foreign keys from partitioned table to
individual partitions.
so when we add new partition, how to create fkconstraint structure based on
pg_constraint tuple?
a Get the foreign key constraints from pg_constraint tuples for partitioned
table, heap_modify_tuple to store relationid of newly added partition,
Insert the new tuple directly into pg_constraint assuming required checks
are happened at the time creating constraint on base table. update
dependencies OR
b call ATAddForeignKeyConstraint with recreated FkConstraint based on
pg_constraint tuple.
Is there any better way?

In both cases I have to create FkConstraint structure, Creating
FkConstraints will also be helpful in adding FkTriggers. I am not sure about
how to create fkconstraint->pk_attrs and fkconstraint->fk_attrs? probably we
can use something similar to decompile_column_index_array. We can get
remaing variables from pg_constraint tuple.
any suggestions appreciated.

Thanks,
Shrish

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2009-06-24 20:43:36 Re: Extensions User Design
Previous Message David E. Wheeler 2009-06-24 16:05:12 Re: Extensions User Design