Re: Fix unsafe coding in ResourceOwnerReleaseAll()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rahila Syed <rahilasyed90(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: Fix unsafe coding in ResourceOwnerReleaseAll()
Date: 2026-06-25 05:15:47
Message-ID: 1062704.1782364547@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Rahila Syed <rahilasyed90(at)gmail(dot)com> writes:
> Unrelated to the patch but I noticed a typo in the ERROR message in
> ResourceOwnerReleaseAllOfKind().

>> /* Mustn't call this after we have already started releasing resources. */
>> if (owner->releasing)
>> elog(ERROR, "ResourceOwnerForget called for %s after release started", kind->name);

Hmm, that definitely looks like a message that was transposed from
someplace else without much thought. It might be worth tracing the
git history to see how it got to be like that.

More: unless I'm missing something, ResourceOwnerReleaseAllOfKind
is called only from plancache.c's ReleaseAllPlanCacheRefsInOwner,
which is called only in some very random-looking ways in plpgsql.
I wonder whether there's not a bigger cleanup project indicated here.
When I posted before, I thought that ResourceOwnerReleaseAllOfKind had
a direct lineage to the old ResourceOwner code, but now I'm thinking
maybe it shouldn't exist at all. Why should plpgsql be taking special
care for particular kinds of resource entries, and why should it
suppose that it owns all instances of that kind within that resowner?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2026-06-25 05:25:41 Re: In core use of RegisterXactCallback() and RegisterSubXactCallback()
Previous Message Kyotaro Horiguchi 2026-06-25 05:15:09 Re: glob support in extension_control_path/dynamic_library_path?