diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2020-04-08 09:59:27 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2020-04-08 11:19:23 +0200 |
commit | 83fd4532a72179c370e318075a10e0e2aa832024 (patch) | |
tree | 9c3c582fe39c51278949eb4b5cd0cbcb0ddd685a /src/backend/utils/cache/relcache.c | |
parent | 1aac32df89eb19949050f6f27c268122833ad036 (diff) | |
download | postgresql-83fd4532a72179c370e318075a10e0e2aa832024.tar.gz postgresql-83fd4532a72179c370e318075a10e0e2aa832024.zip |
Allow publishing partition changes via ancestors
To control whether partition changes are replicated using their own
identity and schema or an ancestor's, add a new parameter that can be
set per publication named 'publish_via_partition_root'.
This allows replicating a partitioned table into a different partition
structure on the subscriber.
Author: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Rafia Sabih <rafia.pghackers@gmail.com>
Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Reviewed-by: Petr Jelinek <petr@2ndquadrant.com>
Discussion: https://www.postgresql.org/message-id/flat/CA+HiwqH=Y85vRK3mOdjEkqFK+E=ST=eQiHdpj43L=_eJMOOznQ@mail.gmail.com
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r-- | src/backend/utils/cache/relcache.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index dfd81f1320e..9f1f11d0c14 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -44,6 +44,7 @@ #include "catalog/catalog.h" #include "catalog/indexing.h" #include "catalog/namespace.h" +#include "catalog/partition.h" #include "catalog/pg_am.h" #include "catalog/pg_amproc.h" #include "catalog/pg_attrdef.h" @@ -5314,6 +5315,20 @@ GetRelationPublicationActions(Relation relation) /* Fetch the publication membership info. */ puboids = GetRelationPublications(RelationGetRelid(relation)); + if (relation->rd_rel->relispartition) + { + /* Add publications that the ancestors are in too. */ + List *ancestors = get_partition_ancestors(RelationGetRelid(relation)); + ListCell *lc; + + foreach(lc, ancestors) + { + Oid ancestor = lfirst_oid(lc); + + puboids = list_concat_unique_oid(puboids, + GetRelationPublications(ancestor)); + } + } puboids = list_concat_unique_oid(puboids, GetAllTablesPublications()); foreach(lc, puboids) |