#include "commands/event_trigger.h"
#include "commands/subscriptioncmds.h"
+#include "executor/executor.h"
+
#include "nodes/makefuncs.h"
#include "replication/logicallauncher.h"
relid = RangeVarGetRelid(rv, AccessShareLock, false);
+ /* Check for supported relkind. */
+ CheckSubscriptionRelkind(get_rel_relkind(relid),
+ rv->schemaname, rv->relname);
+
SetSubscriptionRelState(subid, relid, table_state,
InvalidXLogRecPtr);
}
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,
RelationGetRelationName(rel)),
errhint("To enable deleting from the table, set REPLICA IDENTITY using ALTER TABLE.")));
}
+
+
+/*
+ * Check if we support writing into specific relkind.
+ *
+ * The nspname and relname are only needed for error reporting.
+ */
+void
+CheckSubscriptionRelkind(char relkind, const char *nspname,
+ const char *relname)
+{
+ /*
+ * We currently only support writing to regular tables.
+ */
+ if (relkind != RELKIND_RELATION)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("logical replication target relation \"%s.%s\" is not a table",
+ nspname, relname)));
+}
#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"
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
TupleTableSlot *searchslot);
extern void CheckCmdReplicaIdentity(Relation rel, CmdType cmd);
+extern void CheckSubscriptionRelkind(char relkind, const char *nspname,
+ const char *relname);
#endif /* EXECUTOR_H */