postgres.git / summary / log / commit / refs

commit    b8f953d8d7bff6ca5d7fc8cb0f37a9d3d7a7462b
Author:   Amit Kapila <akapila@postgresql.org>
Date:     Thu Jun 27 05:49:57 2024 +0000
First released in: 17.0, 15.8, 16.4

    Drop the temporary tuple slots allocated by pgoutput.
    
    In pgoutput, when converting the child table's tuple format to match the
    parent table's, we temporarily create a new slot to store the converted
    tuple. However, we missed to drop such temporary slots, leading to
    resource leakage.
    
    Reported-by: Bowen Shi
    Author: Hou Zhijie
    Reviewed-by: Amit Kapila
    Backpatch-through: 15
    Discussion: https://postgr.es/m/CAM_vCudv8dc3sjWiPkXx5F2b27UV7_YRKRbtSCcE-pv=cVACGA@mail.gmail.com


src/backend/replication/pgoutput/pgoutput.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 05688cd41ce..c57c5ed8de9 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -1549,6 +1549,16 @@ cleanup: ancestor = NULL; } + /* Drop the new slots that were used to store the converted tuples. */ + if (relentry->attrmap) + { + if (old_slot) + ExecDropSingleTupleTableSlot(old_slot); + + if (new_slot) + ExecDropSingleTupleTableSlot(new_slot); + } + MemoryContextSwitchTo(old); MemoryContextReset(data->context); } [parent: 6f61d0e7e2f1]