🌐 AI搜索 & 代理 主页
Skip to content

Commit e8dc581

Browse files
committed
Fix some near-bugs related to ResourceOwner function arguments
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
1 parent 1756b9f commit e8dc581

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/backend/storage/aio/aio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
static inline void pgaio_io_update_state(PgAioHandle *ioh, PgAioHandleState new_state);
5555
static void pgaio_io_reclaim(PgAioHandle *ioh);
56-
static void pgaio_io_resowner_register(PgAioHandle *ioh);
56+
static void pgaio_io_resowner_register(PgAioHandle *ioh, struct ResourceOwnerData *resowner);
5757
static void pgaio_io_wait_for_free(void);
5858
static PgAioHandle *pgaio_io_from_wref(PgAioWaitRef *iow, uint64 *ref_generation);
5959
static const char *pgaio_io_state_get_name(PgAioHandleState s);
@@ -217,7 +217,7 @@ pgaio_io_acquire_nb(struct ResourceOwnerData *resowner, PgAioReturn *ret)
217217
pgaio_my_backend->handed_out_io = ioh;
218218

219219
if (resowner)
220-
pgaio_io_resowner_register(ioh);
220+
pgaio_io_resowner_register(ioh, resowner);
221221

222222
if (ret)
223223
{
@@ -406,13 +406,13 @@ pgaio_io_update_state(PgAioHandle *ioh, PgAioHandleState new_state)
406406
}
407407

408408
static void
409-
pgaio_io_resowner_register(PgAioHandle *ioh)
409+
pgaio_io_resowner_register(PgAioHandle *ioh, struct ResourceOwnerData *resowner)
410410
{
411411
Assert(!ioh->resowner);
412-
Assert(CurrentResourceOwner);
412+
Assert(resowner);
413413

414-
ResourceOwnerRememberAioHandle(CurrentResourceOwner, &ioh->resowner_node);
415-
ioh->resowner = CurrentResourceOwner;
414+
ResourceOwnerRememberAioHandle(resowner, &ioh->resowner_node);
415+
ioh->resowner = resowner;
416416
}
417417

418418
/*

src/backend/utils/cache/catcache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ ReleaseCatCacheWithOwner(HeapTuple tuple, ResourceOwner resowner)
16611661

16621662
ct->refcount--;
16631663
if (resowner)
1664-
ResourceOwnerForgetCatCacheRef(CurrentResourceOwner, &ct->tuple);
1664+
ResourceOwnerForgetCatCacheRef(resowner, &ct->tuple);
16651665

16661666
if (
16671667
#ifndef CATCACHE_FORCE_RELEASE
@@ -2103,7 +2103,7 @@ ReleaseCatCacheListWithOwner(CatCList *list, ResourceOwner resowner)
21032103
Assert(list->refcount > 0);
21042104
list->refcount--;
21052105
if (resowner)
2106-
ResourceOwnerForgetCatCacheListRef(CurrentResourceOwner, list);
2106+
ResourceOwnerForgetCatCacheListRef(resowner, list);
21072107

21082108
if (
21092109
#ifndef CATCACHE_FORCE_RELEASE

0 commit comments

Comments
 (0)