1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Support adding partitioned tables to publication

When a partitioned table is added to a publication, changes of all of
its partitions (current or future) are published via that publication.

This change only affects which tables a publication considers as its
members.  The receiving side still sees the data coming from the
individual leaf partitions.  So existing restrictions that partition
hierarchies can only be replicated one-to-one are not changed by this.

Author: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Rafia Sabih <rafia.pghackers@gmail.com>
Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Discussion: https://www.postgresql.org/message-id/flat/CA+HiwqH=Y85vRK3mOdjEkqFK+E=ST=eQiHdpj43L=_eJMOOznQ@mail.gmail.com
This commit is contained in:
Peter Eisentraut
2020-03-10 08:42:59 +01:00
parent 61d7c7bce3
commit 17b9e7f9fe
11 changed files with 382 additions and 44 deletions

View File

@ -402,13 +402,16 @@
<listitem>
<para>
Replication is only possible from base tables to base tables. That is,
the tables on the publication and on the subscription side must be normal
tables, not views, materialized views, partition root tables, or foreign
tables. In the case of partitions, you can therefore replicate a
partition hierarchy one-to-one, but you cannot currently replicate to a
differently partitioned setup. Attempts to replicate tables other than
base tables will result in an error.
Replication is only supported by tables, partitioned or not, although a
given table must either be partitioned on both servers or not partitioned
at all. Also, when replicating between partitioned tables, the actual
replication occurs between leaf partitions, so partitions on the two
servers must match one-to-one.
</para>
<para>
Attempts to replicate other types of relations such as views, materialized
views, or foreign tables, will result in an error.
</para>
</listitem>
</itemizedlist>

View File

@ -69,14 +69,23 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
specified, the table and all its descendant tables (if any) are added.
Optionally, <literal>*</literal> can be specified after the table name to
explicitly indicate that descendant tables are included.
This does not apply to a partitioned table, however. The partitions of
a partitioned table are always implicitly considered part of the
publication, so they are never explicitly added to the publication.
</para>
<para>
Only persistent base tables can be part of a publication. Temporary
tables, unlogged tables, foreign tables, materialized views, regular
views, and partitioned tables cannot be part of a publication. To
replicate a partitioned table, add the individual partitions to the
publication.
Only persistent base tables and partitioned tables can be part of a
publication. Temporary tables, unlogged tables, foreign tables,
materialized views, and regular views cannot be part of a publication.
</para>
<para>
When a partitioned table is added to a publication, all of its existing
and future partitions are implicitly considered to be part of the
publication. So, even operations that are performed directly on a
partition are also published via publications that its ancestors are
part of.
</para>
</listitem>
</varlistentry>