how can we propagate fk constraints?

Поиск
Список
Период
Сортировка
От shrish purohit
Тема how can we propagate fk constraints?
Дата
Msg-id 69b219810906241107x5f6b6a36se666f78df1380182@mail.gmail.com
обсуждение исходный текст
Список pgsql-hackers
Hi All,
 
- 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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jeremy Ford
Дата:
Сообщение: Re: [BUGS] BUG #4862: different results in to_date() between 8.3.7 & 8.4.RC1
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Extensions User Design