Hi, There appears to be a consensus in thread [1] regarding the removal of the ResourceOwnerReleaseAllOfKind function. It contains errors and is rarely used, except in a few instances within the plpgsql code. Furthermore, in those cases, it releases all resources held by the resource owner instead of releasing resources of a specific kind. It mainly exists to bypass the three-phase resource release mechanism.
So here is an attempt to add better-designed code to allow releasing all resources of a resource owner without using the three phase release mechanism when it is not needed. Attached patch adds a new ResourceReleasePhase value, RESOURCE_RELEASE_AT_ONCE. A ResourceOwnerRelease(owner, RESOURCE_RELEASE_AT_ONCE, ...) call sorts the owner's resources as usual, then releases every remaining entry regardless of its individual release_phase, without breaking out between phases. Leak warnings are unconditionally suppressed for this phase, since anything found is by definition meant to be released here, not left behind by mistake. ResourceOwnerReleaseAllOfKind() is removed, and the plpgsql call sites each make one ResourceOwnerRelease() call instead of three phased ones. A secondary cleanup results from this: `releasing` and `sorted` were two separate booleans in `ResourceOwnerData` only because `ResourceOwnerReleaseAllOfKind()` needed to set `releasing` without sorting. With that function gone, the two flags are always set together, so they collapse into one flag(releasing). This approach maintains a single release path via ResourceOwnerRelease function call and avoids maintaining two separate functions that perform nearly the same task. Kindly let me know your views. [1] https://www.postgresql.org/message-id/flat/646741.1782157515%40sss.pgh.pa.us Best Regards, Rahila Syed
0001-Add-RESOURCE_RELEASE_AT_ONCE-phase-remove-ResourceOw.patch
Description: Binary data
