docs about FKs referencing partitioned tables

From: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: docs about FKs referencing partitioned tables
Date: 2019-05-21 04:42:52
Message-ID: CA+renyUuSmYgmZjKc_DfUNVZ0uttF91-FwhDVW3F7WEPj0jL5w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I posted this to the "clean up docs for v12" thread and it was
suggested I make a new thread instead, so here it is. Sorry for the
extra noise! :-)

I noticed the docs at
https://www.postgresql.org/docs/devel/ddl-partitioning.html still say
you can't create a foreign key referencing a partitioned table, even
though the docs for
https://www.postgresql.org/docs/devel/sql-createtable.html have been
updated (compared to v11). My understanding is that foreign keys
*still* don't work as expected when pointing at traditional INHERITS
tables, but they *will* work with declaratively-partitioned tables. In
that case I suggest this change:

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index a0a7435a03..3b4f43bbad 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3966,14 +3966,6 @@ ALTER TABLE measurement ATTACH PARTITION
measurement_y2008m02

- <listitem>
- <para>
- While primary keys are supported on partitioned tables, foreign
- keys referencing partitioned tables are not supported. (Foreign key
- references from a partitioned table to some other table are supported.)
- </para>
- </listitem>
-
<listitem>
<para>
<literal>BEFORE ROW</literal> triggers, if necessary, must be defined
on individual partitions, not the partitioned table.
</para>
@@ -4366,6 +4358,14 @@ ALTER TABLE measurement_y2008m02 INHERIT measurement;
</para>
</listitem>

+ <listitem>
+ <para>
+ While primary keys are supported on inheritance-partitioned
tables, foreign
+ keys referencing these tables are not supported. (Foreign key
+ references from an inheritance-partitioned table to some other
table are supported.)
+ </para>
+ </listitem>
+
<listitem>
<para>
If you are using manual <command>VACUUM</command> or

(I've also attached it as a patch file.) In other words, we should
move this caveat from the section on declaratively-partitioned tables
to the section on inheritance-partitioned tables.

Yours,
Paul

Attachment Content-Type Size
inheritance_fk_docs_v0001.patch application/octet-stream 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2019-05-21 04:43:46 Re: clean up docs for v12
Previous Message Paul A Jungwirth 2019-05-21 04:39:51 Re: clean up docs for v12