diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index c57c5ed8de9..bb8f3ea702f 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -2046,10 +2046,34 @@ get_rel_sync_entry(PGOutputData *data, Relation relation) * Tuple slots cleanups. (Will be rebuilt later if needed). */ if (entry->old_slot) + { + TupleDesc desc = entry->old_slot->tts_tupleDescriptor; + + Assert(desc->tdrefcount == -1); + ExecDropSingleTupleTableSlot(entry->old_slot); + + /* + * ExecDropSingleTupleTableSlot() would not free the TupleDesc, so + * do it now to avoid any leaks. + */ + FreeTupleDesc(desc); + } if (entry->new_slot) + { + TupleDesc desc = entry->new_slot->tts_tupleDescriptor; + + Assert(desc->tdrefcount == -1); + ExecDropSingleTupleTableSlot(entry->new_slot); + /* + * ExecDropSingleTupleTableSlot() would not free the TupleDesc, so + * do it now to avoid any leaks. + */ + FreeTupleDesc(desc); + } + entry->old_slot = NULL; entry->new_slot = NULL;