aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/logical/relation.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-05-16 22:57:16 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-05-16 22:57:16 -0400
commit944dc0f9cec7c3d33648f41aaecfbd976106e975 (patch)
tree62b2499c3f057a28e0f8e7cac96e769929115a3f /src/backend/replication/logical/relation.c
parent0fbfb65d4bfd429651dc28faf3ad1846c965e18d (diff)
downloadpostgresql-944dc0f9cec7c3d33648f41aaecfbd976106e975.tar.gz
postgresql-944dc0f9cec7c3d33648f41aaecfbd976106e975.zip
Check relkind of tables in CREATE/ALTER SUBSCRIPTION
We used to only check for a supported relkind on the subscriber during replication, which is needed to ensure that the setup is valid and we don't crash. But it's also useful to tell the user immediately when CREATE or ALTER SUBSCRIPTION is executed that the relation being added to the subscription is not of a supported relkind. Author: Petr Jelinek <petr.jelinek@2ndquadrant.com> Reported-by: tushar <tushar.ahuja@enterprisedb.com>
Diffstat (limited to 'src/backend/replication/logical/relation.c')
-rw-r--r--src/backend/replication/logical/relation.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index 7c93bfb80a0..590355a846e 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -20,6 +20,7 @@
#include "access/sysattr.h"
#include "catalog/namespace.h"
#include "catalog/pg_subscription_rel.h"
+#include "executor/executor.h"
#include "nodes/makefuncs.h"
#include "replication/logicalrelation.h"
#include "replication/worker_internal.h"
@@ -258,15 +259,9 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
remoterel->nspname, remoterel->relname)));
entry->localrel = heap_open(relid, NoLock);
- /*
- * We currently only support writing to regular and partitioned
- * tables.
- */
- if (entry->localrel->rd_rel->relkind != RELKIND_RELATION)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("logical replication target relation \"%s.%s\" is not a table",
- remoterel->nspname, remoterel->relname)));
+ /* Check for supported relkind. */
+ CheckSubscriptionRelkind(entry->localrel->rd_rel->relkind,
+ remoterel->nspname, remoterel->relname);
/*
* Build the mapping of local attribute numbers to remote attribute