Re: Fix unsafe coding in ResourceOwnerReleaseAll()
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Rahila Syed <rahilasyed90@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org, Heikki Linnakangas <hlinnaka@iki.fi>
Date: 2026-06-25T05:15:47Z
Lists: pgsql-hackers
Rahila Syed <rahilasyed90@gmail.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
Commits
-
Fix unsafe order of operations in ResourceOwnerReleaseAll().
- ef01ca6dbca5 19 (unreleased) landed
- ac6a58a700da 18 (unreleased) landed
- 011eedcdc3fe 17 (unreleased) landed