]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix some near-bugs related to ResourceOwner function arguments
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 10 Dec 2025 09:43:16 +0000 (11:43 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 10 Dec 2025 09:44:07 +0000 (11:44 +0200)
These functions took a ResourceOwner argument, but only checked if it
was NULL, and then used CurrentResourceOwner for the actual work.
Surely the intention was to use the passed-in resource owner. All
current callers passed CurrentResourceOwner or NULL, so this has no
consequences at the moment, but it's an accident waiting to happen for
future caller and extensions.

Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAEze2Whnfv8VuRZaohE-Af+GxBA1SNfD_rXfm84Jv-958UCcJA@mail.gmail.com
Backpatch-through: 17

src/backend/utils/cache/catcache.c

index 59d625b244c72174d6bfe0557dbb187a22f0032f..59d3825917b819c907406db4dd21572b0589f7fb 100644 (file)
@@ -1638,7 +1638,7 @@ ReleaseCatCacheWithOwner(HeapTuple tuple, ResourceOwner resowner)
 
        ct->refcount--;
        if (resowner)
-               ResourceOwnerForgetCatCacheRef(CurrentResourceOwner, &ct->tuple);
+               ResourceOwnerForgetCatCacheRef(resowner, &ct->tuple);
 
        if (
 #ifndef CATCACHE_FORCE_RELEASE
@@ -2083,7 +2083,7 @@ ReleaseCatCacheListWithOwner(CatCList *list, ResourceOwner resowner)
        Assert(list->refcount > 0);
        list->refcount--;
        if (resowner)
-               ResourceOwnerForgetCatCacheListRef(CurrentResourceOwner, list);
+               ResourceOwnerForgetCatCacheListRef(resowner, list);
 
        if (
 #ifndef CATCACHE_FORCE_RELEASE