PostgreSQL Source Code  git master
resowner.c File Reference
#include "postgres.h"
#include "access/hash.h"
#include "jit/jit.h"
#include "storage/predicate.h"
#include "storage/proc.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/resowner_private.h"
#include "utils/snapmgr.h"
Include dependency graph for resowner.c:

Go to the source code of this file.

Data Structures

struct  ResourceArray
 
struct  ResourceOwnerData
 
struct  ResourceReleaseCallbackItem
 

Macros

#define FileGetDatum(file)   Int32GetDatum(file)
 
#define DatumGetFile(datum)   ((File) DatumGetInt32(datum))
 
#define BufferGetDatum(buffer)   Int32GetDatum(buffer)
 
#define DatumGetBuffer(datum)   ((Buffer) DatumGetInt32(datum))
 
#define RESARRAY_INIT_SIZE   16
 
#define RESARRAY_MAX_ARRAY   64
 
#define RESARRAY_IS_ARRAY(resarr)   ((resarr)->capacity <= RESARRAY_MAX_ARRAY)
 
#define RESARRAY_MAX_ITEMS(capacity)   ((capacity) <= RESARRAY_MAX_ARRAY ? (capacity) : (capacity)/4 * 3)
 
#define MAX_RESOWNER_LOCKS   15
 

Typedefs

typedef struct ResourceArray ResourceArray
 
typedef struct ResourceOwnerData ResourceOwnerData
 
typedef struct ResourceReleaseCallbackItem ResourceReleaseCallbackItem
 

Functions

static void ResourceArrayInit (ResourceArray *resarr, Datum invalidval)
 
static void ResourceArrayEnlarge (ResourceArray *resarr)
 
static void ResourceArrayAdd (ResourceArray *resarr, Datum value)
 
static bool ResourceArrayRemove (ResourceArray *resarr, Datum value)
 
static bool ResourceArrayGetAny (ResourceArray *resarr, Datum *value)
 
static void ResourceArrayFree (ResourceArray *resarr)
 
static void ResourceOwnerReleaseInternal (ResourceOwner owner, ResourceReleasePhase phase, bool isCommit, bool isTopLevel)
 
static void PrintRelCacheLeakWarning (Relation rel)
 
static void PrintPlanCacheLeakWarning (CachedPlan *plan)
 
static void PrintTupleDescLeakWarning (TupleDesc tupdesc)
 
static void PrintSnapshotLeakWarning (Snapshot snapshot)
 
static void PrintFileLeakWarning (File file)
 
static void PrintDSMLeakWarning (dsm_segment *seg)
 
ResourceOwner ResourceOwnerCreate (ResourceOwner parent, const char *name)
 
void ResourceOwnerRelease (ResourceOwner owner, ResourceReleasePhase phase, bool isCommit, bool isTopLevel)
 
void ResourceOwnerDelete (ResourceOwner owner)
 
ResourceOwner ResourceOwnerGetParent (ResourceOwner owner)
 
void ResourceOwnerNewParent (ResourceOwner owner, ResourceOwner newparent)
 
void RegisterResourceReleaseCallback (ResourceReleaseCallback callback, void *arg)
 
void UnregisterResourceReleaseCallback (ResourceReleaseCallback callback, void *arg)
 
void ResourceOwnerEnlargeBuffers (ResourceOwner owner)
 
void ResourceOwnerRememberBuffer (ResourceOwner owner, Buffer buffer)
 
void ResourceOwnerForgetBuffer (ResourceOwner owner, Buffer buffer)
 
void ResourceOwnerRememberLock (ResourceOwner owner, LOCALLOCK *locallock)
 
void ResourceOwnerForgetLock (ResourceOwner owner, LOCALLOCK *locallock)
 
void ResourceOwnerEnlargeCatCacheRefs (ResourceOwner owner)
 
void ResourceOwnerRememberCatCacheRef (ResourceOwner owner, HeapTuple tuple)
 
void ResourceOwnerForgetCatCacheRef (ResourceOwner owner, HeapTuple tuple)
 
void ResourceOwnerEnlargeCatCacheListRefs (ResourceOwner owner)
 
void ResourceOwnerRememberCatCacheListRef (ResourceOwner owner, CatCList *list)
 
void ResourceOwnerForgetCatCacheListRef (ResourceOwner owner, CatCList *list)
 
void ResourceOwnerEnlargeRelationRefs (ResourceOwner owner)
 
void ResourceOwnerRememberRelationRef (ResourceOwner owner, Relation rel)
 
void ResourceOwnerForgetRelationRef (ResourceOwner owner, Relation rel)
 
void ResourceOwnerEnlargePlanCacheRefs (ResourceOwner owner)
 
void ResourceOwnerRememberPlanCacheRef (ResourceOwner owner, CachedPlan *plan)
 
void ResourceOwnerForgetPlanCacheRef (ResourceOwner owner, CachedPlan *plan)
 
void ResourceOwnerEnlargeTupleDescs (ResourceOwner owner)
 
void ResourceOwnerRememberTupleDesc (ResourceOwner owner, TupleDesc tupdesc)
 
void ResourceOwnerForgetTupleDesc (ResourceOwner owner, TupleDesc tupdesc)
 
void ResourceOwnerEnlargeSnapshots (ResourceOwner owner)
 
void ResourceOwnerRememberSnapshot (ResourceOwner owner, Snapshot snapshot)
 
void ResourceOwnerForgetSnapshot (ResourceOwner owner, Snapshot snapshot)
 
void ResourceOwnerEnlargeFiles (ResourceOwner owner)
 
void ResourceOwnerRememberFile (ResourceOwner owner, File file)
 
void ResourceOwnerForgetFile (ResourceOwner owner, File file)
 
void ResourceOwnerEnlargeDSMs (ResourceOwner owner)
 
void ResourceOwnerRememberDSM (ResourceOwner owner, dsm_segment *seg)
 
void ResourceOwnerForgetDSM (ResourceOwner owner, dsm_segment *seg)
 
void ResourceOwnerEnlargeJIT (ResourceOwner owner)
 
void ResourceOwnerRememberJIT (ResourceOwner owner, Datum handle)
 
void ResourceOwnerForgetJIT (ResourceOwner owner, Datum handle)
 

Variables

ResourceOwner CurrentResourceOwner = NULL
 
ResourceOwner CurTransactionResourceOwner = NULL
 
ResourceOwner TopTransactionResourceOwner = NULL
 
static ResourceReleaseCallbackItemResourceRelease_callbacks = NULL
 

Macro Definition Documentation

◆ BufferGetDatum

#define BufferGetDatum (   buffer)    Int32GetDatum(buffer)

◆ DatumGetBuffer

#define DatumGetBuffer (   datum)    ((Buffer) DatumGetInt32(datum))

Definition at line 43 of file resowner.c.

Referenced by ResourceOwnerReleaseInternal().

◆ DatumGetFile

#define DatumGetFile (   datum)    ((File) DatumGetInt32(datum))

Definition at line 41 of file resowner.c.

Referenced by ResourceOwnerReleaseInternal().

◆ FileGetDatum

#define FileGetDatum (   file)    Int32GetDatum(file)

◆ MAX_RESOWNER_LOCKS

#define MAX_RESOWNER_LOCKS   15

◆ RESARRAY_INIT_SIZE

#define RESARRAY_INIT_SIZE   16

Definition at line 75 of file resowner.c.

Referenced by ResourceArrayEnlarge().

◆ RESARRAY_IS_ARRAY

#define RESARRAY_IS_ARRAY (   resarr)    ((resarr)->capacity <= RESARRAY_MAX_ARRAY)

Definition at line 81 of file resowner.c.

Referenced by ResourceArrayAdd(), ResourceArrayGetAny(), and ResourceArrayRemove().

◆ RESARRAY_MAX_ARRAY

#define RESARRAY_MAX_ARRAY   64

Definition at line 80 of file resowner.c.

◆ RESARRAY_MAX_ITEMS

#define RESARRAY_MAX_ITEMS (   capacity)    ((capacity) <= RESARRAY_MAX_ARRAY ? (capacity) : (capacity)/4 * 3)

Definition at line 87 of file resowner.c.

Referenced by ResourceArrayEnlarge().

Typedef Documentation

◆ ResourceArray

◆ ResourceOwnerData

◆ ResourceReleaseCallbackItem

Function Documentation

◆ PrintDSMLeakWarning()

static void PrintDSMLeakWarning ( dsm_segment seg)
static

Definition at line 1264 of file resowner.c.

References dsm_segment_handle(), elog, and WARNING.

Referenced by ResourceOwnerReleaseInternal().

1265 {
1266  elog(WARNING, "dynamic shared memory leak: segment %u still referenced",
1267  dsm_segment_handle(seg));
1268 }
dsm_handle dsm_segment_handle(dsm_segment *seg)
Definition: dsm.c:1015
#define WARNING
Definition: elog.h:40
#define elog
Definition: elog.h:219

◆ PrintFileLeakWarning()

static void PrintFileLeakWarning ( File  file)
static

Definition at line 1219 of file resowner.c.

References elog, and WARNING.

Referenced by ResourceOwnerReleaseInternal().

1220 {
1221  elog(WARNING, "temporary file leak: File %d still referenced",
1222  file);
1223 }
#define WARNING
Definition: elog.h:40
#define elog
Definition: elog.h:219

◆ PrintPlanCacheLeakWarning()

static void PrintPlanCacheLeakWarning ( CachedPlan plan)
static

Definition at line 1083 of file resowner.c.

References elog, and WARNING.

Referenced by ResourceOwnerReleaseInternal().

1084 {
1085  elog(WARNING, "plancache reference leak: plan %p not closed", plan);
1086 }
#define WARNING
Definition: elog.h:40
#define elog
Definition: elog.h:219

◆ PrintRelCacheLeakWarning()

static void PrintRelCacheLeakWarning ( Relation  rel)
static

Definition at line 1038 of file resowner.c.

References elog, RelationGetRelationName, and WARNING.

Referenced by ResourceOwnerReleaseInternal().

1039 {
1040  elog(WARNING, "relcache reference leak: relation \"%s\" not closed",
1042 }
#define RelationGetRelationName(relation)
Definition: rel.h:441
#define WARNING
Definition: elog.h:40
#define elog
Definition: elog.h:219

◆ PrintSnapshotLeakWarning()

static void PrintSnapshotLeakWarning ( Snapshot  snapshot)
static

Definition at line 1173 of file resowner.c.

References elog, and WARNING.

Referenced by ResourceOwnerReleaseInternal().

1174 {
1175  elog(WARNING, "Snapshot reference leak: Snapshot %p still referenced",
1176  snapshot);
1177 }
#define WARNING
Definition: elog.h:40
#define elog
Definition: elog.h:219

◆ PrintTupleDescLeakWarning()

static void PrintTupleDescLeakWarning ( TupleDesc  tupdesc)
static

Definition at line 1127 of file resowner.c.

References elog, tupleDesc::tdtypeid, tupleDesc::tdtypmod, and WARNING.

Referenced by ResourceOwnerReleaseInternal().

1128 {
1129  elog(WARNING,
1130  "TupleDesc reference leak: TupleDesc %p (%u,%d) still referenced",
1131  tupdesc, tupdesc->tdtypeid, tupdesc->tdtypmod);
1132 }
Oid tdtypeid
Definition: tupdesc.h:83
int32 tdtypmod
Definition: tupdesc.h:84
#define WARNING
Definition: elog.h:40
#define elog
Definition: elog.h:219

◆ RegisterResourceReleaseCallback()

void RegisterResourceReleaseCallback ( ResourceReleaseCallback  callback,
void *  arg 
)

Definition at line 792 of file resowner.c.

References arg, ResourceReleaseCallbackItem::arg, callback(), ResourceReleaseCallbackItem::callback, MemoryContextAlloc(), ResourceReleaseCallbackItem::next, ResourceRelease_callbacks, and TopMemoryContext.

Referenced by px_find_cipher(), and px_find_digest().

793 {
795 
796  item = (ResourceReleaseCallbackItem *)
799  item->callback = callback;
800  item->arg = arg;
803 }
static ResourceReleaseCallbackItem * ResourceRelease_callbacks
Definition: resowner.c:154
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
MemoryContext TopMemoryContext
Definition: mcxt.c:44
struct ResourceReleaseCallbackItem * next
Definition: resowner.c:149
ResourceReleaseCallback callback
Definition: resowner.c:150
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:771
void * arg

◆ ResourceArrayAdd()

static void ResourceArrayAdd ( ResourceArray resarr,
Datum  value 
)
static

Definition at line 259 of file resowner.c.

References Assert, ResourceArray::capacity, DatumGetUInt32, hash_any(), idx(), ResourceArray::invalidval, ResourceArray::itemsarr, ResourceArray::lastidx, ResourceArray::maxitems, ResourceArray::nitems, RESARRAY_IS_ARRAY, and value.

Referenced by ResourceArrayEnlarge(), ResourceOwnerRememberBuffer(), ResourceOwnerRememberCatCacheListRef(), ResourceOwnerRememberCatCacheRef(), ResourceOwnerRememberDSM(), ResourceOwnerRememberFile(), ResourceOwnerRememberJIT(), ResourceOwnerRememberPlanCacheRef(), ResourceOwnerRememberRelationRef(), ResourceOwnerRememberSnapshot(), and ResourceOwnerRememberTupleDesc().

260 {
261  uint32 idx;
262 
263  Assert(value != resarr->invalidval);
264  Assert(resarr->nitems < resarr->maxitems);
265 
266  if (RESARRAY_IS_ARRAY(resarr))
267  {
268  /* Append to linear array. */
269  idx = resarr->nitems;
270  }
271  else
272  {
273  /* Insert into first free slot at or after hash location. */
274  uint32 mask = resarr->capacity - 1;
275 
276  idx = DatumGetUInt32(hash_any((void *) &value, sizeof(value))) & mask;
277  for (;;)
278  {
279  if (resarr->itemsarr[idx] == resarr->invalidval)
280  break;
281  idx = (idx + 1) & mask;
282  }
283  }
284  resarr->lastidx = idx;
285  resarr->itemsarr[idx] = value;
286  resarr->nitems++;
287 }
#define DatumGetUInt32(X)
Definition: postgres.h:469
uint32 lastidx
Definition: resowner.c:68
uint32 capacity
Definition: resowner.c:65
Datum idx(PG_FUNCTION_ARGS)
Definition: _int_op.c:264
Datum * itemsarr
Definition: resowner.c:63
Datum invalidval
Definition: resowner.c:64
unsigned int uint32
Definition: c.h:325
uint32 maxitems
Definition: resowner.c:67
static struct @131 value
#define Assert(condition)
Definition: c.h:699
Datum hash_any(register const unsigned char *k, register int keylen)
Definition: hashfunc.c:428
#define RESARRAY_IS_ARRAY(resarr)
Definition: resowner.c:81
uint32 nitems
Definition: resowner.c:66

◆ ResourceArrayEnlarge()

static void ResourceArrayEnlarge ( ResourceArray resarr)
static

Definition at line 204 of file resowner.c.

References Assert, ResourceArray::capacity, i, ResourceArray::invalidval, ResourceArray::itemsarr, ResourceArray::maxitems, MemoryContextAlloc(), ResourceArray::nitems, pfree(), RESARRAY_INIT_SIZE, RESARRAY_MAX_ITEMS, ResourceArrayAdd(), and TopMemoryContext.

Referenced by ResourceOwnerEnlargeBuffers(), ResourceOwnerEnlargeCatCacheListRefs(), ResourceOwnerEnlargeCatCacheRefs(), ResourceOwnerEnlargeDSMs(), ResourceOwnerEnlargeFiles(), ResourceOwnerEnlargeJIT(), ResourceOwnerEnlargePlanCacheRefs(), ResourceOwnerEnlargeRelationRefs(), ResourceOwnerEnlargeSnapshots(), and ResourceOwnerEnlargeTupleDescs().

205 {
206  uint32 i,
207  oldcap,
208  newcap;
209  Datum *olditemsarr;
210  Datum *newitemsarr;
211 
212  if (resarr->nitems < resarr->maxitems)
213  return; /* no work needed */
214 
215  olditemsarr = resarr->itemsarr;
216  oldcap = resarr->capacity;
217 
218  /* Double the capacity of the array (capacity must stay a power of 2!) */
219  newcap = (oldcap > 0) ? oldcap * 2 : RESARRAY_INIT_SIZE;
220  newitemsarr = (Datum *) MemoryContextAlloc(TopMemoryContext,
221  newcap * sizeof(Datum));
222  for (i = 0; i < newcap; i++)
223  newitemsarr[i] = resarr->invalidval;
224 
225  /* We assume we can't fail below this point, so OK to scribble on resarr */
226  resarr->itemsarr = newitemsarr;
227  resarr->capacity = newcap;
228  resarr->maxitems = RESARRAY_MAX_ITEMS(newcap);
229  resarr->nitems = 0;
230 
231  if (olditemsarr != NULL)
232  {
233  /*
234  * Transfer any pre-existing entries into the new array; they don't
235  * necessarily go where they were before, so this simple logic is the
236  * best way. Note that if we were managing the set as a simple array,
237  * the entries after nitems are garbage, but that shouldn't matter
238  * because we won't get here unless nitems was equal to oldcap.
239  */
240  for (i = 0; i < oldcap; i++)
241  {
242  if (olditemsarr[i] != resarr->invalidval)
243  ResourceArrayAdd(resarr, olditemsarr[i]);
244  }
245 
246  /* And release old array. */
247  pfree(olditemsarr);
248  }
249 
250  Assert(resarr->nitems < resarr->maxitems);
251 }
#define RESARRAY_INIT_SIZE
Definition: resowner.c:75
uint32 capacity
Definition: resowner.c:65
#define RESARRAY_MAX_ITEMS(capacity)
Definition: resowner.c:87
void pfree(void *pointer)
Definition: mcxt.c:1031
Datum * itemsarr
Definition: resowner.c:63
Datum invalidval
Definition: resowner.c:64
unsigned int uint32
Definition: c.h:325
MemoryContext TopMemoryContext
Definition: mcxt.c:44
uint32 maxitems
Definition: resowner.c:67
uintptr_t Datum
Definition: postgres.h:365
#define Assert(condition)
Definition: c.h:699
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:771
int i
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:259
uint32 nitems
Definition: resowner.c:66

◆ ResourceArrayFree()

static void ResourceArrayFree ( ResourceArray resarr)
static

Definition at line 398 of file resowner.c.

References ResourceArray::itemsarr, and pfree().

Referenced by ResourceOwnerDelete().

399 {
400  if (resarr->itemsarr)
401  pfree(resarr->itemsarr);
402 }
void pfree(void *pointer)
Definition: mcxt.c:1031
Datum * itemsarr
Definition: resowner.c:63

◆ ResourceArrayGetAny()

static bool ResourceArrayGetAny ( ResourceArray resarr,
Datum value 
)
static

Definition at line 366 of file resowner.c.

References ResourceArray::capacity, ResourceArray::invalidval, ResourceArray::itemsarr, ResourceArray::lastidx, ResourceArray::nitems, and RESARRAY_IS_ARRAY.

Referenced by ResourceOwnerReleaseInternal().

367 {
368  if (resarr->nitems == 0)
369  return false;
370 
371  if (RESARRAY_IS_ARRAY(resarr))
372  {
373  /* Linear array: just return the first element. */
374  resarr->lastidx = 0;
375  }
376  else
377  {
378  /* Hash: search forward from wherever we were last. */
379  uint32 mask = resarr->capacity - 1;
380 
381  for (;;)
382  {
383  resarr->lastidx &= mask;
384  if (resarr->itemsarr[resarr->lastidx] != resarr->invalidval)
385  break;
386  resarr->lastidx++;
387  }
388  }
389 
390  *value = resarr->itemsarr[resarr->lastidx];
391  return true;
392 }
uint32 lastidx
Definition: resowner.c:68
uint32 capacity
Definition: resowner.c:65
Datum * itemsarr
Definition: resowner.c:63
Datum invalidval
Definition: resowner.c:64
unsigned int uint32
Definition: c.h:325
static struct @131 value
#define RESARRAY_IS_ARRAY(resarr)
Definition: resowner.c:81
uint32 nitems
Definition: resowner.c:66

◆ ResourceArrayInit()

static void ResourceArrayInit ( ResourceArray resarr,
Datum  invalidval 
)
static

Definition at line 185 of file resowner.c.

References Assert, ResourceArray::capacity, ResourceArray::invalidval, ResourceArray::itemsarr, ResourceArray::maxitems, and ResourceArray::nitems.

Referenced by ResourceOwnerCreate().

186 {
187  /* Assert it's empty */
188  Assert(resarr->itemsarr == NULL);
189  Assert(resarr->capacity == 0);
190  Assert(resarr->nitems == 0);
191  Assert(resarr->maxitems == 0);
192  /* Remember the appropriate "invalid" value */
193  resarr->invalidval = invalidval;
194  /* We don't allocate any storage until needed */
195 }
uint32 capacity
Definition: resowner.c:65
Datum * itemsarr
Definition: resowner.c:63
Datum invalidval
Definition: resowner.c:64
uint32 maxitems
Definition: resowner.c:67
#define Assert(condition)
Definition: c.h:699
uint32 nitems
Definition: resowner.c:66

◆ ResourceArrayRemove()

static bool ResourceArrayRemove ( ResourceArray resarr,
Datum  value 
)
static

Definition at line 297 of file resowner.c.

References Assert, ResourceArray::capacity, DatumGetUInt32, hash_any(), i, idx(), ResourceArray::invalidval, ResourceArray::itemsarr, ResourceArray::lastidx, ResourceArray::nitems, and RESARRAY_IS_ARRAY.

Referenced by ResourceOwnerForgetBuffer(), ResourceOwnerForgetCatCacheListRef(), ResourceOwnerForgetCatCacheRef(), ResourceOwnerForgetDSM(), ResourceOwnerForgetFile(), ResourceOwnerForgetJIT(), ResourceOwnerForgetPlanCacheRef(), ResourceOwnerForgetRelationRef(), ResourceOwnerForgetSnapshot(), and ResourceOwnerForgetTupleDesc().

298 {
299  uint32 i,
300  idx,
301  lastidx = resarr->lastidx;
302 
303  Assert(value != resarr->invalidval);
304 
305  /* Search through all items, but try lastidx first. */
306  if (RESARRAY_IS_ARRAY(resarr))
307  {
308  if (lastidx < resarr->nitems &&
309  resarr->itemsarr[lastidx] == value)
310  {
311  resarr->itemsarr[lastidx] = resarr->itemsarr[resarr->nitems - 1];
312  resarr->nitems--;
313  /* Update lastidx to make reverse-order removals fast. */
314  resarr->lastidx = resarr->nitems - 1;
315  return true;
316  }
317  for (i = 0; i < resarr->nitems; i++)
318  {
319  if (resarr->itemsarr[i] == value)
320  {
321  resarr->itemsarr[i] = resarr->itemsarr[resarr->nitems - 1];
322  resarr->nitems--;
323  /* Update lastidx to make reverse-order removals fast. */
324  resarr->lastidx = resarr->nitems - 1;
325  return true;
326  }
327  }
328  }
329  else
330  {
331  uint32 mask = resarr->capacity - 1;
332 
333  if (lastidx < resarr->capacity &&
334  resarr->itemsarr[lastidx] == value)
335  {
336  resarr->itemsarr[lastidx] = resarr->invalidval;
337  resarr->nitems--;
338  return true;
339  }
340  idx = DatumGetUInt32(hash_any((void *) &value, sizeof(value))) & mask;
341  for (i = 0; i < resarr->capacity; i++)
342  {
343  if (resarr->itemsarr[idx] == value)
344  {
345  resarr->itemsarr[idx] = resarr->invalidval;
346  resarr->nitems--;
347  return true;
348  }
349  idx = (idx + 1) & mask;
350  }
351  }
352 
353  return false;
354 }
#define DatumGetUInt32(X)
Definition: postgres.h:469
uint32 lastidx
Definition: resowner.c:68
uint32 capacity
Definition: resowner.c:65
Datum idx(PG_FUNCTION_ARGS)
Definition: _int_op.c:264
Datum * itemsarr
Definition: resowner.c:63
Datum invalidval
Definition: resowner.c:64
unsigned int uint32
Definition: c.h:325
static struct @131 value
#define Assert(condition)
Definition: c.h:699
Datum hash_any(register const unsigned char *k, register int keylen)
Definition: hashfunc.c:428
int i
#define RESARRAY_IS_ARRAY(resarr)
Definition: resowner.c:81
uint32 nitems
Definition: resowner.c:66

◆ ResourceOwnerCreate()

ResourceOwner ResourceOwnerCreate ( ResourceOwner  parent,
const char *  name 
)

Definition at line 418 of file resowner.c.

References ResourceOwnerData::bufferarr, BufferGetDatum, ResourceOwnerData::catlistrefarr, ResourceOwnerData::catrefarr, ResourceOwnerData::dsmarr, ResourceOwnerData::filearr, FileGetDatum, ResourceOwnerData::firstchild, InvalidBuffer, ResourceOwnerData::jitarr, MemoryContextAllocZero(), ResourceOwnerData::name, name, ResourceOwnerData::nextchild, ResourceOwnerData::parent, ResourceOwnerData::planrefarr, PointerGetDatum, ResourceOwnerData::relrefarr, ResourceArrayInit(), ResourceOwnerData::snapshotarr, TopMemoryContext, and ResourceOwnerData::tupdescarr.

Referenced by ApplyWorkerMain(), AtStart_ResourceOwner(), AtSubStart_ResourceOwner(), BackgroundWriterMain(), CheckpointerMain(), CreatePortal(), ParallelWorkerMain(), pg_logical_replication_slot_advance(), pg_logical_slot_get_changes_guts(), test_shm_mq_main(), WalReceiverMain(), and WalWriterMain().

419 {
420  ResourceOwner owner;
421 
423  sizeof(ResourceOwnerData));
424  owner->name = name;
425 
426  if (parent)
427  {
428  owner->parent = parent;
429  owner->nextchild = parent->firstchild;
430  parent->firstchild = owner;
431  }
432 
434  ResourceArrayInit(&(owner->catrefarr), PointerGetDatum(NULL));
436  ResourceArrayInit(&(owner->relrefarr), PointerGetDatum(NULL));
437  ResourceArrayInit(&(owner->planrefarr), PointerGetDatum(NULL));
438  ResourceArrayInit(&(owner->tupdescarr), PointerGetDatum(NULL));
440  ResourceArrayInit(&(owner->filearr), FileGetDatum(-1));
441  ResourceArrayInit(&(owner->dsmarr), PointerGetDatum(NULL));
442  ResourceArrayInit(&(owner->jitarr), PointerGetDatum(NULL));
443 
444  return owner;
445 }
ResourceArray relrefarr
Definition: resowner.c:122
ResourceArray catrefarr
Definition: resowner.c:120
#define PointerGetDatum(X)
Definition: postgres.h:539
#define InvalidBuffer
Definition: buf.h:25
ResourceArray bufferarr
Definition: resowner.c:119
ResourceArray snapshotarr
Definition: resowner.c:125
struct ResourceOwnerData * ResourceOwner
Definition: resowner.h:27
const char * name
Definition: resowner.c:116
ResourceArray planrefarr
Definition: resowner.c:123
ResourceArray tupdescarr
Definition: resowner.c:124
static void ResourceArrayInit(ResourceArray *resarr, Datum invalidval)
Definition: resowner.c:185
MemoryContext TopMemoryContext
Definition: mcxt.c:44
ResourceOwner firstchild
Definition: resowner.c:114
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:814
#define BufferGetDatum(buffer)
Definition: resowner.c:42
#define FileGetDatum(file)
Definition: resowner.c:40
ResourceArray jitarr
Definition: resowner.c:128
ResourceOwner parent
Definition: resowner.c:113
const char * name
Definition: encode.c:521
ResourceArray catlistrefarr
Definition: resowner.c:121
ResourceArray dsmarr
Definition: resowner.c:127
ResourceOwner nextchild
Definition: resowner.c:115
ResourceArray filearr
Definition: resowner.c:126

◆ ResourceOwnerDelete()

void ResourceOwnerDelete ( ResourceOwner  owner)

Definition at line 684 of file resowner.c.

References Assert, ResourceOwnerData::bufferarr, ResourceOwnerData::catlistrefarr, ResourceOwnerData::catrefarr, ResourceOwnerData::dsmarr, ResourceOwnerData::filearr, ResourceOwnerData::firstchild, ResourceOwnerData::jitarr, MAX_RESOWNER_LOCKS, ResourceArray::nitems, ResourceOwnerData::nlocks, pfree(), ResourceOwnerData::planrefarr, ResourceOwnerData::relrefarr, ResourceArrayFree(), ResourceOwnerDelete(), ResourceOwnerNewParent(), ResourceOwnerData::snapshotarr, and ResourceOwnerData::tupdescarr.

Referenced by CleanupSubTransaction(), CleanupTransaction(), CommitSubTransaction(), CommitTransaction(), PortalDrop(), PrepareTransaction(), and ResourceOwnerDelete().

685 {
686  /* We had better not be deleting CurrentResourceOwner ... */
687  Assert(owner != CurrentResourceOwner);
688 
689  /* And it better not own any resources, either */
690  Assert(owner->bufferarr.nitems == 0);
691  Assert(owner->catrefarr.nitems == 0);
692  Assert(owner->catlistrefarr.nitems == 0);
693  Assert(owner->relrefarr.nitems == 0);
694  Assert(owner->planrefarr.nitems == 0);
695  Assert(owner->tupdescarr.nitems == 0);
696  Assert(owner->snapshotarr.nitems == 0);
697  Assert(owner->filearr.nitems == 0);
698  Assert(owner->dsmarr.nitems == 0);
699  Assert(owner->jitarr.nitems == 0);
700  Assert(owner->nlocks == 0 || owner->nlocks == MAX_RESOWNER_LOCKS + 1);
701 
702  /*
703  * Delete children. The recursive call will delink the child from me, so
704  * just iterate as long as there is a child.
705  */
706  while (owner->firstchild != NULL)
708 
709  /*
710  * We delink the owner from its parent before deleting it, so that if
711  * there's an error we won't have deleted/busted owners still attached to
712  * the owner tree. Better a leak than a crash.
713  */
714  ResourceOwnerNewParent(owner, NULL);
715 
716  /* And free the object. */
717  ResourceArrayFree(&(owner->bufferarr));
718  ResourceArrayFree(&(owner->catrefarr));
719  ResourceArrayFree(&(owner->catlistrefarr));
720  ResourceArrayFree(&(owner->relrefarr));
721  ResourceArrayFree(&(owner->planrefarr));
722  ResourceArrayFree(&(owner->tupdescarr));
723  ResourceArrayFree(&(owner->snapshotarr));
724  ResourceArrayFree(&(owner->filearr));
725  ResourceArrayFree(&(owner->dsmarr));
726  ResourceArrayFree(&(owner->jitarr));
727 
728  pfree(owner);
729 }
ResourceArray relrefarr
Definition: resowner.c:122
ResourceArray catrefarr
Definition: resowner.c:120
ResourceOwner CurrentResourceOwner
Definition: resowner.c:140
void ResourceOwnerDelete(ResourceOwner owner)
Definition: resowner.c:684
ResourceArray bufferarr
Definition: resowner.c:119
ResourceArray snapshotarr
Definition: resowner.c:125
#define MAX_RESOWNER_LOCKS
Definition: resowner.c:106
void pfree(void *pointer)
Definition: mcxt.c:1031
ResourceArray planrefarr
Definition: resowner.c:123
static void ResourceArrayFree(ResourceArray *resarr)
Definition: resowner.c:398
ResourceArray tupdescarr
Definition: resowner.c:124
ResourceOwner firstchild
Definition: resowner.c:114
#define Assert(condition)
Definition: c.h:699
ResourceArray jitarr
Definition: resowner.c:128
void ResourceOwnerNewParent(ResourceOwner owner, ResourceOwner newparent)
Definition: resowner.c:744
ResourceArray catlistrefarr
Definition: resowner.c:121
ResourceArray dsmarr
Definition: resowner.c:127
uint32 nitems
Definition: resowner.c:66
ResourceArray filearr
Definition: resowner.c:126

◆ ResourceOwnerEnlargeBuffers()

void ResourceOwnerEnlargeBuffers ( ResourceOwner  owner)

Definition at line 838 of file resowner.c.

References ResourceOwnerData::bufferarr, and ResourceArrayEnlarge().

Referenced by BgBufferSync(), BufferSync(), FlushDatabaseBuffers(), FlushRelationBuffers(), IncrBufferRefCount(), and ReadBuffer_common().

839 {
840  if (owner == NULL)
841  return;
842  ResourceArrayEnlarge(&(owner->bufferarr));
843 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:204
ResourceArray bufferarr
Definition: resowner.c:119

◆ ResourceOwnerEnlargeCatCacheListRefs()

void ResourceOwnerEnlargeCatCacheListRefs ( ResourceOwner  owner)

Definition at line 972 of file resowner.c.

References ResourceOwnerData::catlistrefarr, and ResourceArrayEnlarge().

Referenced by SearchCatCacheList().

973 {
975 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:204
ResourceArray catlistrefarr
Definition: resowner.c:121

◆ ResourceOwnerEnlargeCatCacheRefs()

void ResourceOwnerEnlargeCatCacheRefs ( ResourceOwner  owner)

Definition at line 937 of file resowner.c.

References ResourceOwnerData::catrefarr, and ResourceArrayEnlarge().

Referenced by SearchCatCacheInternal(), and SearchCatCacheMiss().

938 {
939  ResourceArrayEnlarge(&(owner->catrefarr));
940 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:204
ResourceArray catrefarr
Definition: resowner.c:120

◆ ResourceOwnerEnlargeDSMs()

void ResourceOwnerEnlargeDSMs ( ResourceOwner  owner)

Definition at line 1233 of file resowner.c.

References ResourceOwnerData::dsmarr, and ResourceArrayEnlarge().

Referenced by dsm_create_descriptor(), and dsm_unpin_mapping().

1234 {
1235  ResourceArrayEnlarge(&(owner->dsmarr));
1236 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:204
ResourceArray dsmarr
Definition: resowner.c:127

◆ ResourceOwnerEnlargeFiles()

void ResourceOwnerEnlargeFiles ( ResourceOwner  owner)

Definition at line 1188 of file resowner.c.

References ResourceOwnerData::filearr, and ResourceArrayEnlarge().

Referenced by OpenTemporaryFile(), PathNameCreateTemporaryFile(), and PathNameOpenTemporaryFile().

1189 {
1190  ResourceArrayEnlarge(&(owner->filearr));
1191 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:204
ResourceArray filearr
Definition: resowner.c:126

◆ ResourceOwnerEnlargeJIT()

void ResourceOwnerEnlargeJIT ( ResourceOwner  owner)

Definition at line 1278 of file resowner.c.

References ResourceOwnerData::jitarr, and ResourceArrayEnlarge().

Referenced by llvm_create_context().

1279 {
1280  ResourceArrayEnlarge(&(owner->jitarr));
1281 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:204
ResourceArray jitarr
Definition: resowner.c:128

◆ ResourceOwnerEnlargePlanCacheRefs()

void ResourceOwnerEnlargePlanCacheRefs ( ResourceOwner  owner)

Definition at line 1052 of file resowner.c.

References ResourceOwnerData::planrefarr, and ResourceArrayEnlarge().

Referenced by GetCachedPlan().

1053 {
1054  ResourceArrayEnlarge(&(owner->planrefarr));
1055 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:204
ResourceArray planrefarr
Definition: resowner.c:123

◆ ResourceOwnerEnlargeRelationRefs()

void ResourceOwnerEnlargeRelationRefs ( ResourceOwner  owner)

Definition at line 1007 of file resowner.c.

References ResourceOwnerData::relrefarr, and ResourceArrayEnlarge().

Referenced by RelationIncrementReferenceCount().

1008 {
1009  ResourceArrayEnlarge(&(owner->relrefarr));
1010 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:204
ResourceArray relrefarr
Definition: resowner.c:122

◆ ResourceOwnerEnlargeSnapshots()

void ResourceOwnerEnlargeSnapshots ( ResourceOwner  owner)

Definition at line 1142 of file resowner.c.

References ResourceArrayEnlarge(), and ResourceOwnerData::snapshotarr.

Referenced by RegisterSnapshotOnOwner().

1143 {
1144  ResourceArrayEnlarge(&(owner->snapshotarr));
1145 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:204
ResourceArray snapshotarr
Definition: resowner.c:125

◆ ResourceOwnerEnlargeTupleDescs()

void ResourceOwnerEnlargeTupleDescs ( ResourceOwner  owner)

Definition at line 1096 of file resowner.c.

References ResourceArrayEnlarge(), and ResourceOwnerData::tupdescarr.

Referenced by IncrTupleDescRefCount().

1097 {
1098  ResourceArrayEnlarge(&(owner->tupdescarr));
1099 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:204
ResourceArray tupdescarr
Definition: resowner.c:124

◆ ResourceOwnerForgetBuffer()

void ResourceOwnerForgetBuffer ( ResourceOwner  owner,
Buffer  buffer 
)

Definition at line 868 of file resowner.c.

References ResourceOwnerData::bufferarr, BufferGetDatum, elog, ERROR, ResourceOwnerData::name, and ResourceArrayRemove().

Referenced by ReleaseAndReadBuffer(), ReleaseBuffer(), and UnpinBuffer().

869 {
870  if (owner == NULL)
871  return;
873  elog(ERROR, "buffer %d is not owned by resource owner %s",
874  buffer, owner->name);
875 }
ResourceArray bufferarr
Definition: resowner.c:119
const char * name
Definition: resowner.c:116
#define ERROR
Definition: elog.h:43
#define BufferGetDatum(buffer)
Definition: resowner.c:42
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:215
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:297
#define elog
Definition: elog.h:219

◆ ResourceOwnerForgetCatCacheListRef()

void ResourceOwnerForgetCatCacheListRef ( ResourceOwner  owner,
CatCList list 
)

Definition at line 992 of file resowner.c.

References ResourceOwnerData::catlistrefarr, elog, ERROR, ResourceOwnerData::name, PointerGetDatum, and ResourceArrayRemove().

Referenced by ReleaseCatCacheList().

993 {
994  if (!ResourceArrayRemove(&(owner->catlistrefarr), PointerGetDatum(list)))
995  elog(ERROR, "catcache list reference %p is not owned by resource owner %s",
996  list, owner->name);
997 }
#define PointerGetDatum(X)
Definition: postgres.h:539
const char * name
Definition: resowner.c:116
#define ERROR
Definition: elog.h:43
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:297
ResourceArray catlistrefarr
Definition: resowner.c:121
#define elog
Definition: elog.h:219

◆ ResourceOwnerForgetCatCacheRef()

void ResourceOwnerForgetCatCacheRef ( ResourceOwner  owner,
HeapTuple  tuple 
)

Definition at line 957 of file resowner.c.

References ResourceOwnerData::catrefarr, elog, ERROR, ResourceOwnerData::name, PointerGetDatum, and ResourceArrayRemove().

Referenced by ReleaseCatCache().

958 {
959  if (!ResourceArrayRemove(&(owner->catrefarr), PointerGetDatum(tuple)))
960  elog(ERROR, "catcache reference %p is not owned by resource owner %s",
961  tuple, owner->name);
962 }
ResourceArray catrefarr
Definition: resowner.c:120
#define PointerGetDatum(X)
Definition: postgres.h:539
const char * name
Definition: resowner.c:116
#define ERROR
Definition: elog.h:43
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:297
#define elog
Definition: elog.h:219

◆ ResourceOwnerForgetDSM()

void ResourceOwnerForgetDSM ( ResourceOwner  owner,
dsm_segment seg 
)

Definition at line 1253 of file resowner.c.

References dsm_segment_handle(), ResourceOwnerData::dsmarr, elog, ERROR, ResourceOwnerData::name, PointerGetDatum, and ResourceArrayRemove().

Referenced by dsm_create(), dsm_detach(), and dsm_pin_mapping().

1254 {
1255  if (!ResourceArrayRemove(&(owner->dsmarr), PointerGetDatum(seg)))
1256  elog(ERROR, "dynamic shared memory segment %u is not owned by resource owner %s",
1257  dsm_segment_handle(seg), owner->name);
1258 }
#define PointerGetDatum(X)
Definition: postgres.h:539
dsm_handle dsm_segment_handle(dsm_segment *seg)
Definition: dsm.c:1015
const char * name
Definition: resowner.c:116
#define ERROR
Definition: elog.h:43
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:297
ResourceArray dsmarr
Definition: resowner.c:127
#define elog
Definition: elog.h:219

◆ ResourceOwnerForgetFile()

void ResourceOwnerForgetFile ( ResourceOwner  owner,
File  file 
)

Definition at line 1208 of file resowner.c.

References elog, ERROR, ResourceOwnerData::filearr, FileGetDatum, ResourceOwnerData::name, and ResourceArrayRemove().

Referenced by FileClose().

1209 {
1210  if (!ResourceArrayRemove(&(owner->filearr), FileGetDatum(file)))
1211  elog(ERROR, "temporary file %d is not owned by resource owner %s",
1212  file, owner->name);
1213 }
const char * name
Definition: resowner.c:116
#define ERROR
Definition: elog.h:43
#define FileGetDatum(file)
Definition: resowner.c:40
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:297
#define elog
Definition: elog.h:219
ResourceArray filearr
Definition: resowner.c:126

◆ ResourceOwnerForgetJIT()

void ResourceOwnerForgetJIT ( ResourceOwner  owner,
Datum  handle 
)

Definition at line 1298 of file resowner.c.

References DatumGetPointer, elog, ERROR, ResourceOwnerData::jitarr, ResourceOwnerData::name, and ResourceArrayRemove().

Referenced by jit_release_context().

1299 {
1300  if (!ResourceArrayRemove(&(owner->jitarr), handle))
1301  elog(ERROR, "JIT context %p is not owned by resource owner %s",
1302  DatumGetPointer(handle), owner->name);
1303 }
const char * name
Definition: resowner.c:116
#define ERROR
Definition: elog.h:43
ResourceArray jitarr
Definition: resowner.c:128
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:297
#define DatumGetPointer(X)
Definition: postgres.h:532
#define elog
Definition: elog.h:219

◆ ResourceOwnerForgetLock()

void ResourceOwnerForgetLock ( ResourceOwner  owner,
LOCALLOCK locallock 
)

Definition at line 908 of file resowner.c.

References Assert, elog, ERROR, i, ResourceOwnerData::locks, MAX_RESOWNER_LOCKS, ResourceOwnerData::name, and ResourceOwnerData::nlocks.

Referenced by LockReassignOwner(), LockRelease(), LockReleaseAll(), ReleaseLockIfHeld(), and RemoveLocalLock().

909 {
910  int i;
911 
912  if (owner->nlocks > MAX_RESOWNER_LOCKS)
913  return; /* we have overflowed */
914 
915  Assert(owner->nlocks > 0);
916  for (i = owner->nlocks - 1; i >= 0; i--)
917  {
918  if (locallock == owner->locks[i])
919  {
920  owner->locks[i] = owner->locks[owner->nlocks - 1];
921  owner->nlocks--;
922  return;
923  }
924  }
925  elog(ERROR, "lock reference %p is not owned by resource owner %s",
926  locallock, owner->name);
927 }
#define MAX_RESOWNER_LOCKS
Definition: resowner.c:106
const char * name
Definition: resowner.c:116
#define ERROR
Definition: elog.h:43
#define Assert(condition)
Definition: c.h:699
LOCALLOCK * locks[MAX_RESOWNER_LOCKS]
Definition: resowner.c:132
int i
#define elog
Definition: elog.h:219

◆ ResourceOwnerForgetPlanCacheRef()

void ResourceOwnerForgetPlanCacheRef ( ResourceOwner  owner,
CachedPlan plan 
)

Definition at line 1072 of file resowner.c.

References elog, ERROR, ResourceOwnerData::name, ResourceOwnerData::planrefarr, PointerGetDatum, and ResourceArrayRemove().

Referenced by ReleaseCachedPlan().

1073 {
1074  if (!ResourceArrayRemove(&(owner->planrefarr), PointerGetDatum(plan)))
1075  elog(ERROR, "plancache reference %p is not owned by resource owner %s",
1076  plan, owner->name);
1077 }
#define PointerGetDatum(X)
Definition: postgres.h:539
const char * name
Definition: resowner.c:116
#define ERROR
Definition: elog.h:43
ResourceArray planrefarr
Definition: resowner.c:123
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:297
#define elog
Definition: elog.h:219

◆ ResourceOwnerForgetRelationRef()

void ResourceOwnerForgetRelationRef ( ResourceOwner  owner,
Relation  rel 
)

Definition at line 1027 of file resowner.c.

References elog, ERROR, ResourceOwnerData::name, PointerGetDatum, RelationGetRelationName, ResourceOwnerData::relrefarr, and ResourceArrayRemove().

Referenced by RelationDecrementReferenceCount().

1028 {
1029  if (!ResourceArrayRemove(&(owner->relrefarr), PointerGetDatum(rel)))
1030  elog(ERROR, "relcache reference %s is not owned by resource owner %s",
1031  RelationGetRelationName(rel), owner->name);
1032 }
ResourceArray relrefarr
Definition: resowner.c:122
#define PointerGetDatum(X)
Definition: postgres.h:539
const char * name
Definition: resowner.c:116
#define ERROR
Definition: elog.h:43
#define RelationGetRelationName(relation)
Definition: rel.h:441
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:297
#define elog
Definition: elog.h:219

◆ ResourceOwnerForgetSnapshot()

void ResourceOwnerForgetSnapshot ( ResourceOwner  owner,
Snapshot  snapshot 
)

Definition at line 1162 of file resowner.c.

References elog, ERROR, ResourceOwnerData::name, PointerGetDatum, ResourceArrayRemove(), and ResourceOwnerData::snapshotarr.

Referenced by UnregisterSnapshotFromOwner().

1163 {
1164  if (!ResourceArrayRemove(&(owner->snapshotarr), PointerGetDatum(snapshot)))
1165  elog(ERROR, "snapshot reference %p is not owned by resource owner %s",
1166  snapshot, owner->name);
1167 }
#define PointerGetDatum(X)
Definition: postgres.h:539
ResourceArray snapshotarr
Definition: resowner.c:125
const char * name
Definition: resowner.c:116
#define ERROR
Definition: elog.h:43
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:297
#define elog
Definition: elog.h:219

◆ ResourceOwnerForgetTupleDesc()

void ResourceOwnerForgetTupleDesc ( ResourceOwner  owner,
TupleDesc  tupdesc 
)

Definition at line 1116 of file resowner.c.

References elog, ERROR, ResourceOwnerData::name, PointerGetDatum, ResourceArrayRemove(), and ResourceOwnerData::tupdescarr.

Referenced by DecrTupleDescRefCount().

1117 {
1118  if (!ResourceArrayRemove(&(owner->tupdescarr), PointerGetDatum(tupdesc)))
1119  elog(ERROR, "tupdesc reference %p is not owned by resource owner %s",
1120  tupdesc, owner->name);
1121 }
#define PointerGetDatum(X)
Definition: postgres.h:539
const char * name
Definition: resowner.c:116
#define ERROR
Definition: elog.h:43
ResourceArray tupdescarr
Definition: resowner.c:124
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:297
#define elog
Definition: elog.h:219

◆ ResourceOwnerGetParent()

ResourceOwner ResourceOwnerGetParent ( ResourceOwner  owner)

Definition at line 735 of file resowner.c.

References ResourceOwnerData::parent.

Referenced by LockReassignCurrentOwner().

736 {
737  return owner->parent;
738 }
ResourceOwner parent
Definition: resowner.c:113

◆ ResourceOwnerNewParent()

void ResourceOwnerNewParent ( ResourceOwner  owner,
ResourceOwner  newparent 
)

Definition at line 744 of file resowner.c.

References Assert, ResourceOwnerData::firstchild, ResourceOwnerData::nextchild, and ResourceOwnerData::parent.

Referenced by AtSubAbort_Portals(), AtSubCommit_Portals(), and ResourceOwnerDelete().

746 {
747  ResourceOwner oldparent = owner->parent;
748 
749  if (oldparent)
750  {
751  if (owner == oldparent->firstchild)
752  oldparent->firstchild = owner->nextchild;
753  else
754  {
755  ResourceOwner child;
756 
757  for (child = oldparent->firstchild; child; child = child->nextchild)
758  {
759  if (owner == child->nextchild)
760  {
761  child->nextchild = owner->nextchild;
762  break;
763  }
764  }
765  }
766  }
767 
768  if (newparent)
769  {
770  Assert(owner != newparent);
771  owner->parent = newparent;
772  owner->nextchild = newparent->firstchild;
773  newparent->firstchild = owner;
774  }
775  else
776  {
777  owner->parent = NULL;
778  owner->nextchild = NULL;
779  }
780 }
ResourceOwner firstchild
Definition: resowner.c:114
#define Assert(condition)
Definition: c.h:699
ResourceOwner parent
Definition: resowner.c:113
ResourceOwner nextchild
Definition: resowner.c:115

◆ ResourceOwnerRelease()

void ResourceOwnerRelease ( ResourceOwner  owner,
ResourceReleasePhase  phase,
bool  isCommit,
bool  isTopLevel 
)

Definition at line 474 of file resowner.c.

References ResourceOwnerReleaseInternal().

Referenced by AbortSubTransaction(), AbortTransaction(), AutoVacLauncherMain(), BackgroundWriterMain(), CheckpointerMain(), CommitSubTransaction(), CommitTransaction(), PortalDrop(), PrepareTransaction(), and WalWriterMain().

478 {
479  /* There's not currently any setup needed before recursing */
480  ResourceOwnerReleaseInternal(owner, phase, isCommit, isTopLevel);
481 }
static void ResourceOwnerReleaseInternal(ResourceOwner owner, ResourceReleasePhase phase, bool isCommit, bool isTopLevel)
Definition: resowner.c:484

◆ ResourceOwnerReleaseInternal()

static void ResourceOwnerReleaseInternal ( ResourceOwner  owner,
ResourceReleasePhase  phase,
bool  isCommit,
bool  isTopLevel 
)
static

Definition at line 484 of file resowner.c.

References ResourceReleaseCallbackItem::arg, Assert, ResourceOwnerData::bufferarr, ResourceReleaseCallbackItem::callback, ResourceOwnerData::catlistrefarr, ResourceOwnerData::catrefarr, CurrentResourceOwner, DatumGetBuffer, DatumGetFile, DatumGetPointer, DecrTupleDescRefCount(), dsm_detach(), ResourceOwnerData::dsmarr, ResourceOwnerData::filearr, FileClose(), ResourceOwnerData::firstchild, jit_release_context(), ResourceOwnerData::jitarr, LockReassignCurrentOwner(), LockReleaseCurrentOwner(), ResourceOwnerData::locks, MAX_RESOWNER_LOCKS, ResourceReleaseCallbackItem::next, ResourceOwnerData::nextchild, ResourceOwnerData::nlocks, ResourceOwnerData::parent, ResourceOwnerData::planrefarr, PointerGetDatum, PrintBufferLeakWarning(), PrintCatCacheLeakWarning(), PrintCatCacheListLeakWarning(), PrintDSMLeakWarning(), PrintFileLeakWarning(), PrintPlanCacheLeakWarning(), PrintRelCacheLeakWarning(), PrintSnapshotLeakWarning(), PrintTupleDescLeakWarning(), ProcReleaseLocks(), RelationClose(), ReleaseBuffer(), ReleaseCachedPlan(), ReleaseCatCache(), ReleaseCatCacheList(), ReleasePredicateLocks(), ResourceOwnerData::relrefarr, RESOURCE_RELEASE_AFTER_LOCKS, RESOURCE_RELEASE_BEFORE_LOCKS, RESOURCE_RELEASE_LOCKS, ResourceArrayGetAny(), ResourceOwnerData::snapshotarr, ResourceOwnerData::tupdescarr, and UnregisterSnapshot().

Referenced by ResourceOwnerRelease().

488 {
489  ResourceOwner child;
490  ResourceOwner save;
492  Datum foundres;
493 
494  /* Recurse to handle descendants */
495  for (child = owner->firstchild; child != NULL; child = child->nextchild)
496  ResourceOwnerReleaseInternal(child, phase, isCommit, isTopLevel);
497 
498  /*
499  * Make CurrentResourceOwner point to me, so that ReleaseBuffer etc don't
500  * get confused.
501  */
502  save = CurrentResourceOwner;
503  CurrentResourceOwner = owner;
504 
505  if (phase == RESOURCE_RELEASE_BEFORE_LOCKS)
506  {
507  /*
508  * Release buffer pins. Note that ReleaseBuffer will remove the
509  * buffer entry from our array, so we just have to iterate till there
510  * are none.
511  *
512  * During a commit, there shouldn't be any remaining pins --- that
513  * would indicate failure to clean up the executor correctly --- so
514  * issue warnings. In the abort case, just clean up quietly.
515  */
516  while (ResourceArrayGetAny(&(owner->bufferarr), &foundres))
517  {
518  Buffer res = DatumGetBuffer(foundres);
519 
520  if (isCommit)
522  ReleaseBuffer(res);
523  }
524 
525  /* Ditto for relcache references */
526  while (ResourceArrayGetAny(&(owner->relrefarr), &foundres))
527  {
528  Relation res = (Relation) DatumGetPointer(foundres);
529 
530  if (isCommit)
532  RelationClose(res);
533  }
534 
535  /* Ditto for dynamic shared memory segments */
536  while (ResourceArrayGetAny(&(owner->dsmarr), &foundres))
537  {
538  dsm_segment *res = (dsm_segment *) DatumGetPointer(foundres);
539 
540  if (isCommit)
541  PrintDSMLeakWarning(res);
542  dsm_detach(res);
543  }
544 
545  /* Ditto for JIT contexts */
546  while (ResourceArrayGetAny(&(owner->jitarr), &foundres))
547  {
548  JitContext *context = (JitContext *) PointerGetDatum(foundres);
549 
550  jit_release_context(context);
551  }
552  }
553  else if (phase == RESOURCE_RELEASE_LOCKS)
554  {
555  if (isTopLevel)
556  {
557  /*
558  * For a top-level xact we are going to release all locks (or at
559  * least all non-session locks), so just do a single lmgr call at
560  * the top of the recursion.
561  */
562  if (owner == TopTransactionResourceOwner)
563  {
564  ProcReleaseLocks(isCommit);
565  ReleasePredicateLocks(isCommit);
566  }
567  }
568  else
569  {
570  /*
571  * Release locks retail. Note that if we are committing a
572  * subtransaction, we do NOT release its locks yet, but transfer
573  * them to the parent.
574  */
575  LOCALLOCK **locks;
576  int nlocks;
577 
578  Assert(owner->parent != NULL);
579 
580  /*
581  * Pass the list of locks owned by this resource owner to the lock
582  * manager, unless it has overflowed.
583  */
584  if (owner->nlocks > MAX_RESOWNER_LOCKS)
585  {
586  locks = NULL;
587  nlocks = 0;
588  }
589  else
590  {
591  locks = owner->locks;
592  nlocks = owner->nlocks;
593  }
594 
595  if (isCommit)
596  LockReassignCurrentOwner(locks, nlocks);
597  else
598  LockReleaseCurrentOwner(locks, nlocks);
599  }
600  }
601  else if (phase == RESOURCE_RELEASE_AFTER_LOCKS)
602  {
603  /*
604  * Release catcache references. Note that ReleaseCatCache will remove
605  * the catref entry from our array, so we just have to iterate till
606  * there are none.
607  *
608  * As with buffer pins, warn if any are left at commit time.
609  */
610  while (ResourceArrayGetAny(&(owner->catrefarr), &foundres))
611  {
612  HeapTuple res = (HeapTuple) DatumGetPointer(foundres);
613 
614  if (isCommit)
616  ReleaseCatCache(res);
617  }
618 
619  /* Ditto for catcache lists */
620  while (ResourceArrayGetAny(&(owner->catlistrefarr), &foundres))
621  {
622  CatCList *res = (CatCList *) DatumGetPointer(foundres);
623 
624  if (isCommit)
626  ReleaseCatCacheList(res);
627  }
628 
629  /* Ditto for plancache references */
630  while (ResourceArrayGetAny(&(owner->planrefarr), &foundres))
631  {
632  CachedPlan *res = (CachedPlan *) DatumGetPointer(foundres);
633 
634  if (isCommit)
636  ReleaseCachedPlan(res, true);
637  }
638 
639  /* Ditto for tupdesc references */
640  while (ResourceArrayGetAny(&(owner->tupdescarr), &foundres))
641  {
642  TupleDesc res = (TupleDesc) DatumGetPointer(foundres);
643 
644  if (isCommit)
647  }
648 
649  /* Ditto for snapshot references */
650  while (ResourceArrayGetAny(&(owner->snapshotarr), &foundres))
651  {
652  Snapshot res = (Snapshot) DatumGetPointer(foundres);
653 
654  if (isCommit)
656  UnregisterSnapshot(res);
657  }
658 
659  /* Ditto for temporary files */
660  while (ResourceArrayGetAny(&(owner->filearr), &foundres))
661  {
662  File res = DatumGetFile(foundres);
663 
664  if (isCommit)
666  FileClose(res);
667  }
668  }
669 
670  /* Let add-on modules get a chance too */
671  for (item = ResourceRelease_callbacks; item; item = item->next)
672  item->callback(phase, isCommit, isTopLevel, item->arg);
673 
674  CurrentResourceOwner = save;
675 }
ResourceArray relrefarr
Definition: resowner.c:122
void PrintCatCacheListLeakWarning(CatCList *list)
Definition: catcache.c:2115
HeapTupleData * HeapTuple
Definition: htup.h:71
void PrintBufferLeakWarning(Buffer buffer)
Definition: bufmgr.c:2531
ResourceArray catrefarr
Definition: resowner.c:120
#define DatumGetFile(datum)
Definition: resowner.c:41
ResourceOwner TopTransactionResourceOwner
Definition: resowner.c:142
#define PointerGetDatum(X)
Definition: postgres.h:539
ResourceOwner CurrentResourceOwner
Definition: resowner.c:140
Definition: jit.h:27
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3309
ResourceArray bufferarr
Definition: resowner.c:119
static bool ResourceArrayGetAny(ResourceArray *resarr, Datum *value)
Definition: resowner.c:366
ResourceArray snapshotarr
Definition: resowner.c:125
struct SnapshotData * Snapshot
Definition: snapshot.h:23
static void ResourceOwnerReleaseInternal(ResourceOwner owner, ResourceReleasePhase phase, bool isCommit, bool isTopLevel)
Definition: resowner.c:484
static ResourceReleaseCallbackItem * ResourceRelease_callbacks
Definition: resowner.c:154
void ReleaseCatCacheList(CatCList *list)
Definition: catcache.c:1800
#define MAX_RESOWNER_LOCKS
Definition: resowner.c:106
void LockReleaseCurrentOwner(LOCALLOCK **locallocks, int nlocks)
Definition: lock.c:2318
struct RelationData * Relation
Definition: relcache.h:26
static void PrintSnapshotLeakWarning(Snapshot snapshot)
Definition: resowner.c:1173
ResourceArray planrefarr
Definition: resowner.c:123
void LockReassignCurrentOwner(LOCALLOCK **locallocks, int nlocks)
Definition: lock.c:2413
static void PrintPlanCacheLeakWarning(CachedPlan *plan)
Definition: resowner.c:1083
void ReleaseCachedPlan(CachedPlan *plan, bool useResOwner)
Definition: plancache.c:1258
ResourceArray tupdescarr
Definition: resowner.c:124
void ProcReleaseLocks(bool isCommit)
Definition: proc.c:762
void RelationClose(Relation relation)
Definition: relcache.c:1996
void UnregisterSnapshot(Snapshot snapshot)
Definition: snapmgr.c:905
static void PrintRelCacheLeakWarning(Relation rel)
Definition: resowner.c:1038
struct ResourceReleaseCallbackItem * next
Definition: resowner.c:149
uintptr_t Datum
Definition: postgres.h:365
ResourceReleaseCallback callback
Definition: resowner.c:150
ResourceOwner firstchild
Definition: resowner.c:114
void PrintCatCacheLeakWarning(HeapTuple tuple)
Definition: catcache.c:2099
static void PrintTupleDescLeakWarning(TupleDesc tupdesc)
Definition: resowner.c:1127
void ReleaseCatCache(HeapTuple tuple)
Definition: catcache.c:1458
void ReleasePredicateLocks(bool isCommit)
Definition: predicate.c:3222
struct tupleDesc * TupleDesc
void FileClose(File file)
Definition: fd.c:1742
#define Assert(condition)
Definition: c.h:699
void DecrTupleDescRefCount(TupleDesc tupdesc)
Definition: tupdesc.c:391
ResourceArray jitarr
Definition: resowner.c:128
static void PrintFileLeakWarning(File file)
Definition: resowner.c:1219
ResourceOwner parent
Definition: resowner.c:113
#define DatumGetPointer(X)
Definition: postgres.h:532
void dsm_detach(dsm_segment *seg)
Definition: dsm.c:713
#define DatumGetBuffer(datum)
Definition: resowner.c:43
void jit_release_context(JitContext *context)
Definition: jit.c:141
LOCALLOCK * locks[MAX_RESOWNER_LOCKS]
Definition: resowner.c:132
ResourceArray catlistrefarr
Definition: resowner.c:121
ResourceArray dsmarr
Definition: resowner.c:127
ResourceOwner nextchild
Definition: resowner.c:115
static void PrintDSMLeakWarning(dsm_segment *seg)
Definition: resowner.c:1264
int Buffer
Definition: buf.h:23
int File
Definition: fd.h:49
ResourceArray filearr
Definition: resowner.c:126

◆ ResourceOwnerRememberBuffer()

void ResourceOwnerRememberBuffer ( ResourceOwner  owner,
Buffer  buffer 
)

Definition at line 854 of file resowner.c.

References ResourceOwnerData::bufferarr, BufferGetDatum, and ResourceArrayAdd().

Referenced by IncrBufferRefCount(), LocalBufferAlloc(), PinBuffer(), and PinBuffer_Locked().

855 {
856  if (owner == NULL)
857  return;
859 }
ResourceArray bufferarr
Definition: resowner.c:119
#define BufferGetDatum(buffer)
Definition: resowner.c:42
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:215
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:259

◆ ResourceOwnerRememberCatCacheListRef()

void ResourceOwnerRememberCatCacheListRef ( ResourceOwner  owner,
CatCList list 
)

Definition at line 983 of file resowner.c.

References ResourceOwnerData::catlistrefarr, PointerGetDatum, and ResourceArrayAdd().

Referenced by SearchCatCacheList().

984 {
986 }
#define PointerGetDatum(X)
Definition: postgres.h:539
ResourceArray catlistrefarr
Definition: resowner.c:121
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:259

◆ ResourceOwnerRememberCatCacheRef()

void ResourceOwnerRememberCatCacheRef ( ResourceOwner  owner,
HeapTuple  tuple 
)

Definition at line 948 of file resowner.c.

References ResourceOwnerData::catrefarr, PointerGetDatum, and ResourceArrayAdd().

Referenced by SearchCatCacheInternal(), and SearchCatCacheMiss().

949 {
950  ResourceArrayAdd(&(owner->catrefarr), PointerGetDatum(tuple));
951 }
ResourceArray catrefarr
Definition: resowner.c:120
#define PointerGetDatum(X)
Definition: postgres.h:539
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:259

◆ ResourceOwnerRememberDSM()

void ResourceOwnerRememberDSM ( ResourceOwner  owner,
dsm_segment seg 
)

Definition at line 1244 of file resowner.c.

References ResourceOwnerData::dsmarr, PointerGetDatum, and ResourceArrayAdd().

Referenced by dsm_create_descriptor(), and dsm_unpin_mapping().

1245 {
1246  ResourceArrayAdd(&(owner->dsmarr), PointerGetDatum(seg));
1247 }
#define PointerGetDatum(X)
Definition: postgres.h:539
ResourceArray dsmarr
Definition: resowner.c:127
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:259

◆ ResourceOwnerRememberFile()

void ResourceOwnerRememberFile ( ResourceOwner  owner,
File  file 
)

Definition at line 1199 of file resowner.c.

References ResourceOwnerData::filearr, FileGetDatum, and ResourceArrayAdd().

Referenced by RegisterTemporaryFile().

1200 {
1201  ResourceArrayAdd(&(owner->filearr), FileGetDatum(file));
1202 }
#define FileGetDatum(file)
Definition: resowner.c:40
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:259
ResourceArray filearr
Definition: resowner.c:126

◆ ResourceOwnerRememberJIT()

void ResourceOwnerRememberJIT ( ResourceOwner  owner,
Datum  handle 
)

Definition at line 1289 of file resowner.c.

References ResourceOwnerData::jitarr, and ResourceArrayAdd().

Referenced by llvm_create_context().

1290 {
1291  ResourceArrayAdd(&(owner->jitarr), handle);
1292 }
ResourceArray jitarr
Definition: resowner.c:128
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:259

◆ ResourceOwnerRememberLock()

void ResourceOwnerRememberLock ( ResourceOwner  owner,
LOCALLOCK locallock 
)

Definition at line 888 of file resowner.c.

References Assert, ResourceOwnerData::locks, MAX_RESOWNER_LOCKS, and ResourceOwnerData::nlocks.

Referenced by GrantLockLocal(), and LockReassignOwner().

889 {
890  Assert(locallock != NULL);
891 
892  if (owner->nlocks > MAX_RESOWNER_LOCKS)
893  return; /* we have already overflowed */
894 
895  if (owner->nlocks < MAX_RESOWNER_LOCKS)
896  owner->locks[owner->nlocks] = locallock;
897  else
898  {
899  /* overflowed */
900  }
901  owner->nlocks++;
902 }
#define MAX_RESOWNER_LOCKS
Definition: resowner.c:106
#define Assert(condition)
Definition: c.h:699
LOCALLOCK * locks[MAX_RESOWNER_LOCKS]
Definition: resowner.c:132

◆ ResourceOwnerRememberPlanCacheRef()

void ResourceOwnerRememberPlanCacheRef ( ResourceOwner  owner,
CachedPlan plan 
)

Definition at line 1063 of file resowner.c.

References ResourceOwnerData::planrefarr, PointerGetDatum, and ResourceArrayAdd().

Referenced by GetCachedPlan().

1064 {
1065  ResourceArrayAdd(&(owner->planrefarr), PointerGetDatum(plan));
1066 }
#define PointerGetDatum(X)
Definition: postgres.h:539
ResourceArray planrefarr
Definition: resowner.c:123
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:259

◆ ResourceOwnerRememberRelationRef()

void ResourceOwnerRememberRelationRef ( ResourceOwner  owner,
Relation  rel 
)

Definition at line 1018 of file resowner.c.

References PointerGetDatum, ResourceOwnerData::relrefarr, and ResourceArrayAdd().

Referenced by RelationIncrementReferenceCount().

1019 {
1020  ResourceArrayAdd(&(owner->relrefarr), PointerGetDatum(rel));
1021 }
ResourceArray relrefarr
Definition: resowner.c:122
#define PointerGetDatum(X)
Definition: postgres.h:539
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:259

◆ ResourceOwnerRememberSnapshot()

void ResourceOwnerRememberSnapshot ( ResourceOwner  owner,
Snapshot  snapshot 
)

Definition at line 1153 of file resowner.c.

References PointerGetDatum, ResourceArrayAdd(), and ResourceOwnerData::snapshotarr.

Referenced by RegisterSnapshotOnOwner().

1154 {
1155  ResourceArrayAdd(&(owner->snapshotarr), PointerGetDatum(snapshot));
1156 }
#define PointerGetDatum(X)
Definition: postgres.h:539
ResourceArray snapshotarr
Definition: resowner.c:125
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:259

◆ ResourceOwnerRememberTupleDesc()

void ResourceOwnerRememberTupleDesc ( ResourceOwner  owner,
TupleDesc  tupdesc 
)

Definition at line 1107 of file resowner.c.

References PointerGetDatum, ResourceArrayAdd(), and ResourceOwnerData::tupdescarr.

Referenced by IncrTupleDescRefCount().

1108 {
1109  ResourceArrayAdd(&(owner->tupdescarr), PointerGetDatum(tupdesc));
1110 }
#define PointerGetDatum(X)
Definition: postgres.h:539
ResourceArray tupdescarr
Definition: resowner.c:124
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:259

◆ UnregisterResourceReleaseCallback()

void UnregisterResourceReleaseCallback ( ResourceReleaseCallback  callback,
void *  arg 
)

Definition at line 806 of file resowner.c.

References ResourceReleaseCallbackItem::next, and pfree().

807 {
810 
811  prev = NULL;
812  for (item = ResourceRelease_callbacks; item; prev = item, item = item->next)
813  {
814  if (item->callback == callback && item->arg == arg)
815  {
816  if (prev)
817  prev->next = item->next;
818  else
820  pfree(item);
821  break;
822  }
823  }
824 }
static ResourceReleaseCallbackItem * ResourceRelease_callbacks
Definition: resowner.c:154
void pfree(void *pointer)
Definition: mcxt.c:1031
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
struct ResourceReleaseCallbackItem * next
Definition: resowner.c:149
void * arg

Variable Documentation

◆ CurrentResourceOwner

ResourceOwner CurrentResourceOwner = NULL

Definition at line 140 of file resowner.c.

Referenced by ApplyWorkerMain(), AssignTransactionId(), AtAbort_ResourceOwner(), AtStart_ResourceOwner(), AtSubAbort_ResourceOwner(), AtSubStart_ResourceOwner(), AutoVacLauncherMain(), BackgroundWriterMain(), BgBufferSync(), BufferSync(), BufFileCreateShared(), BufFileOpenShared(), CheckpointerMain(), cipher_free_callback(), CleanupSubTransaction(), CleanupTransaction(), close_lo_relation(), CommitSubTransaction(), CommitTransaction(), DecrTupleDescRefCount(), digest_free_callback(), dsm_create_descriptor(), dsm_unpin_mapping(), exec_init_tuple_store(), exec_stmt_block(), extendBufFile(), FlushDatabaseBuffers(), FlushRelationBuffers(), GetCachedPlan(), GetCurrentFDWTuplestore(), IncrBufferRefCount(), IncrTupleDescRefCount(), llvm_create_context(), LocalBufferAlloc(), lock_and_open_sequence(), LockAcquireExtended(), LockReassignCurrentOwner(), LockReassignOwner(), LockRelease(), makeBufFile(), MakeTransitionCaptureState(), open_lo_relation(), OpenTemporaryFile(), ParallelWorkerMain(), PathNameCreateTemporaryFile(), PathNameOpenTemporaryFile(), PersistHoldablePortal(), pg_logical_replication_slot_advance(), pg_logical_slot_get_changes_guts(), PinBuffer(), PinBuffer_Locked(), plperl_spi_exec(), plperl_spi_exec_prepared(), plperl_spi_fetchrow(), plperl_spi_prepare(), plperl_spi_query(), plperl_spi_query_prepared(), plpgsql_estate_setup(), pltcl_func_handler(), pltcl_init_tuple_store(), pltcl_returnnext(), pltcl_SPI_execute(), pltcl_SPI_execute_plan(), pltcl_SPI_prepare(), pltcl_subtrans_abort(), pltcl_subtrans_commit(), pltcl_subtransaction(), PLy_abort_open_subtransactions(), PLy_cursor_fetch(), PLy_cursor_iternext(), PLy_cursor_plan(), PLy_cursor_query(), PLy_spi_execute_plan(), PLy_spi_execute_query(), PLy_spi_prepare(), PLy_spi_subtransaction_abort(), PLy_spi_subtransaction_commit(), PLy_subtransaction_enter(), PLy_subtransaction_exit(), PopTransaction(), PortalCleanup(), PortalRun(), PortalRunFetch(), PortalStart(), PrepareTransaction(), px_find_cipher(), px_find_digest(), ReadBuffer_common(), RegisterSnapshot(), RegisterTemporaryFile(), RelationDecrementReferenceCount(), RelationIncrementReferenceCount(), ReleaseAndReadBuffer(), ReleaseBuffer(), ReleaseCachedPlan(), ReleaseCatCache(), ReleaseCatCacheList(), ReleaseLockIfHeld(), ResourceOwnerReleaseInternal(), SearchCatCacheInternal(), SearchCatCacheList(), SearchCatCacheMiss(), SnapBuildClearExportedSnapshot(), SnapBuildExportSnapshot(), test_shm_mq_main(), tuplestore_begin_common(), tuplestore_puttuple_common(), UnpinBuffer(), UnregisterSnapshot(), WalReceiverMain(), and WalWriterMain().

◆ CurTransactionResourceOwner

◆ ResourceRelease_callbacks

ResourceReleaseCallbackItem* ResourceRelease_callbacks = NULL
static

Definition at line 154 of file resowner.c.

Referenced by RegisterResourceReleaseCallback().

◆ TopTransactionResourceOwner