bool allow_binary_protocol;
bool allow_sendrecv_protocol;
bool int_datetime_mismatch;
+ bool forward_changesets;
uint32 client_pg_version;
uint32 client_pg_catversion;
bdr_parse_bool(elem, &data->client_int_datetime);
else if (strcmp(elem->defname, "db_encoding") == 0)
data->client_db_encoding = pstrdup(strVal(elem->arg));
+ else if (strcmp(elem->defname, "forward_changesets") == 0)
+ bdr_parse_bool(elem, &data->forward_changesets);
else
{
ereport(ERROR,
}
}
+/*
+ * Only changesets generated on the local node should be replicated
+ * to the client unless we're in changeset forwarding mode.
+ */
+static inline bool
+should_forward_changeset(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
+{
+ return (txn->origin_id == InvalidRepNodeId)
+ || ((BdrOutputData*)ctx->output_plugin_private)->forward_changesets;
+}
+
/* BEGIN callback */
void
pg_decode_begin_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
#endif
AssertVariableIsOfType(&pg_decode_begin_txn, LogicalDecodeBeginCB);
- if (txn->origin_id != InvalidRepNodeId)
+ if (!should_forward_changeset(ctx, txn))
return;
OutputPluginPrepareWrite(ctx, true);
BdrOutputData *data = ctx->output_plugin_private;
#endif
- if (txn->origin_id != InvalidRepNodeId)
+ if (!should_forward_changeset(ctx, txn))
return;
OutputPluginPrepareWrite(ctx, true);
/* Avoid leaking memory by using and resetting our own context */
old = MemoryContextSwitchTo(data->context);
- /* only log changes originating locally */
- if (txn->origin_id != InvalidRepNodeId)
+ if (!should_forward_changeset(ctx, txn))
return;
OutputPluginPrepareWrite(ctx, true);