From 944dc0f9cec7c3d33648f41aaecfbd976106e975 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 16 May 2017 22:57:16 -0400 Subject: 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 Reported-by: tushar --- src/backend/commands/subscriptioncmds.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/backend/commands/subscriptioncmds.c') diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index b80af275da5..265f2efd622 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -33,6 +33,8 @@ #include "commands/event_trigger.h" #include "commands/subscriptioncmds.h" +#include "executor/executor.h" + #include "nodes/makefuncs.h" #include "replication/logicallauncher.h" @@ -417,6 +419,10 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) relid = RangeVarGetRelid(rv, AccessShareLock, false); + /* Check for supported relkind. */ + CheckSubscriptionRelkind(get_rel_relkind(relid), + rv->schemaname, rv->relname); + SetSubscriptionRelState(subid, relid, table_state, InvalidXLogRecPtr); } @@ -529,6 +535,11 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data) Oid relid; relid = RangeVarGetRelid(rv, AccessShareLock, false); + + /* Check for supported relkind. */ + CheckSubscriptionRelkind(get_rel_relkind(relid), + rv->schemaname, rv->relname); + pubrel_local_oids[off++] = relid; if (!bsearch(&relid, subrel_local_oids, -- cgit v1.2.3