TransactionId xid);
static void init_tuple_slot(PGOutputData *data, Relation relation,
RelationSyncEntry *entry);
+static void pgoutput_memory_context_reset(void *arg);
/* row filter routines */
static EState *create_estate_for_relation(Relation rel);
}
/*
- * Callback of PGOutputData->context in charge of cleaning pubctx.
+ * Memory context reset callback of PGOutputData->context.
*/
static void
-pgoutput_pubctx_reset_callback(void *arg)
+pgoutput_memory_context_reset(void *arg)
{
+ if (RelationSyncCache)
+ {
+ hash_destroy(RelationSyncCache);
+ RelationSyncCache = NULL;
+ }
+
+ /* Better safe than sorry */
pubctx = NULL;
}
"logical replication publication list context",
ALLOCSET_SMALL_SIZES);
+ /*
+ * Ensure to cleanup RelationSyncCache even when logical decoding invoked
+ * via SQL interface ends up with an error.
+ */
mcallback = palloc0(sizeof(MemoryContextCallback));
- mcallback->func = pgoutput_pubctx_reset_callback;
+ mcallback->func = pgoutput_memory_context_reset;
MemoryContextRegisterResetCallback(ctx->context, mcallback);
ctx->output_plugin_private = data;
static void
pgoutput_shutdown(LogicalDecodingContext *ctx)
{
- if (RelationSyncCache)
- {
- hash_destroy(RelationSyncCache);
- RelationSyncCache = NULL;
- }
-
- /* Better safe than sorry */
- pubctx = NULL;
+ pgoutput_memory_context_reset(NULL);
}
/*