Re: Residual cleanups for tied objects in PL/Perl

From: Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: andrew(at)dunslane(dot)net, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Residual cleanups for tied objects in PL/Perl
Date: 2026-08-18 15:48:14
Message-ID: CAB8bMiu+K_ES9kp4+4hoCCRxX0DxOkrPLuiaNhv6LK09qxOpLQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

вт, 18 авг. 2026 г. в 20:17, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:

> I've not read the whole thing, but I noticed
>
> /*
> * Convert a HE (hash entry) key to a cstr in the current database
> encoding.
> * The result is palloc'd.
> + *
> + * Uses FREETMPS, so call this before hv_iterval() if both are needed.
> */
> static inline char *
> hek2cstr(HE *he)
>
> and you had a similar comment in your earlier draft. I think this is
> nonsense though. hek2cstr does the full ENTER; SAVETMPS; FREETMPS;
> LEAVE; dance, so unless I totally misunderstand that API, it's
> destroying only its own temps not any pre-existing ones. Also,
> if there actually is an ordering dependency there, how is the existing
> coding working (where the two callers of hek2cstr do so in randomly
> different orders?) I changed that ordering in my patch only for
> cosmetic reasons, not because I expect it to make a difference.
>

You are right. The comment can be dropped.

I had read FREETMPS as discarding every mortal in sight. It does not.
SAVETMPS records the current index on the temp stack. FREETMPS only drops
SVs pushed after that mark. The nested ENTER/SAVETMPS/FREETMPS/LEAVE in
hek2cstr() therefore frees the mortal from HeSVKEY_force(), and nothing
that the caller already held.

--
Regards,
Rachitskiy Andrey

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Nidzwetzki 2026-08-18 16:03:01 Re: [PATCH] Add tests for src/backend/nodes/extensible.c
Previous Message Sami Imseih 2026-08-18 15:46:09 Fix GRAPH TABLE label and property error reporting