Go to the source code of this file.
typedef struct ResourceOwnerData* ResourceOwner |
Definition at line 27 of file resowner.h.
typedef void(* ResourceReleaseCallback)(ResourceReleasePhase phase, bool isCommit, bool isTopLevel, void *arg) |
Definition at line 56 of file resowner.h.
enum ResourceReleasePhase |
Definition at line 45 of file resowner.h.
{ RESOURCE_RELEASE_BEFORE_LOCKS, RESOURCE_RELEASE_LOCKS, RESOURCE_RELEASE_AFTER_LOCKS } ResourceReleasePhase;
void RegisterResourceReleaseCallback | ( | ResourceReleaseCallback | callback, | |
void * | arg | |||
) |
Definition at line 506 of file resowner.c.
References ResourceReleaseCallbackItem::arg, ResourceReleaseCallbackItem::callback, MemoryContextAlloc(), ResourceReleaseCallbackItem::next, and TopMemoryContext.
{ ResourceReleaseCallbackItem *item; item = (ResourceReleaseCallbackItem *) MemoryContextAlloc(TopMemoryContext, sizeof(ResourceReleaseCallbackItem)); item->callback = callback; item->arg = arg; item->next = ResourceRelease_callbacks; ResourceRelease_callbacks = item; }
ResourceOwner ResourceOwnerCreate | ( | ResourceOwner | parent, | |
const char * | name | |||
) |
Definition at line 150 of file resowner.c.
References ResourceOwnerData::firstchild, MemoryContextAllocZero(), ResourceOwnerData::name, ResourceOwnerData::nextchild, ResourceOwnerData::parent, and TopMemoryContext.
Referenced by AtStart_ResourceOwner(), AtSubStart_ResourceOwner(), BackgroundWriterMain(), CheckpointerMain(), CreatePortal(), InitWalSender(), WalReceiverMain(), and WalWriterMain().
{ ResourceOwner owner; owner = (ResourceOwner) MemoryContextAllocZero(TopMemoryContext, sizeof(ResourceOwnerData)); owner->name = name; if (parent) { owner->parent = parent; owner->nextchild = parent->firstchild; parent->firstchild = owner; } return owner; }
void ResourceOwnerDelete | ( | ResourceOwner | owner | ) |
Definition at line 394 of file resowner.c.
References Assert, ResourceOwnerData::buffers, ResourceOwnerData::catlistrefs, ResourceOwnerData::catrefs, ResourceOwnerData::files, ResourceOwnerData::firstchild, MAX_RESOWNER_LOCKS, ResourceOwnerData::nbuffers, ResourceOwnerData::ncatlistrefs, ResourceOwnerData::ncatrefs, ResourceOwnerData::nfiles, ResourceOwnerData::nlocks, ResourceOwnerData::nplanrefs, ResourceOwnerData::nrelrefs, ResourceOwnerData::nsnapshots, ResourceOwnerData::ntupdescs, NULL, pfree(), ResourceOwnerData::planrefs, ResourceOwnerData::relrefs, ResourceOwnerDelete(), ResourceOwnerNewParent(), ResourceOwnerData::snapshots, and ResourceOwnerData::tupdescs.
Referenced by CleanupSubTransaction(), CleanupTransaction(), CommitSubTransaction(), CommitTransaction(), PortalDrop(), PrepareTransaction(), and ResourceOwnerDelete().
{ /* We had better not be deleting CurrentResourceOwner ... */ Assert(owner != CurrentResourceOwner); /* And it better not own any resources, either */ Assert(owner->nbuffers == 0); Assert(owner->nlocks == 0 || owner->nlocks == MAX_RESOWNER_LOCKS + 1); Assert(owner->ncatrefs == 0); Assert(owner->ncatlistrefs == 0); Assert(owner->nrelrefs == 0); Assert(owner->nplanrefs == 0); Assert(owner->ntupdescs == 0); Assert(owner->nsnapshots == 0); Assert(owner->nfiles == 0); /* * Delete children. The recursive call will delink the child from me, so * just iterate as long as there is a child. */ while (owner->firstchild != NULL) ResourceOwnerDelete(owner->firstchild); /* * We delink the owner from its parent before deleting it, so that if * there's an error we won't have deleted/busted owners still attached to * the owner tree. Better a leak than a crash. */ ResourceOwnerNewParent(owner, NULL); /* And free the object. */ if (owner->buffers) pfree(owner->buffers); if (owner->catrefs) pfree(owner->catrefs); if (owner->catlistrefs) pfree(owner->catlistrefs); if (owner->relrefs) pfree(owner->relrefs); if (owner->planrefs) pfree(owner->planrefs); if (owner->tupdescs) pfree(owner->tupdescs); if (owner->snapshots) pfree(owner->snapshots); if (owner->files) pfree(owner->files); pfree(owner); }
ResourceOwner ResourceOwnerGetParent | ( | ResourceOwner | owner | ) |
Definition at line 449 of file resowner.c.
References ResourceOwnerData::parent.
Referenced by LockReassignCurrentOwner().
{ return owner->parent; }
void ResourceOwnerNewParent | ( | ResourceOwner | owner, | |
ResourceOwner | newparent | |||
) |
Definition at line 458 of file resowner.c.
References Assert, ResourceOwnerData::firstchild, ResourceOwnerData::nextchild, and ResourceOwnerData::parent.
Referenced by AtSubCommit_Portals(), and ResourceOwnerDelete().
{ ResourceOwner oldparent = owner->parent; if (oldparent) { if (owner == oldparent->firstchild) oldparent->firstchild = owner->nextchild; else { ResourceOwner child; for (child = oldparent->firstchild; child; child = child->nextchild) { if (owner == child->nextchild) { child->nextchild = owner->nextchild; break; } } } } if (newparent) { Assert(owner != newparent); owner->parent = newparent; owner->nextchild = newparent->firstchild; newparent->firstchild = owner; } else { owner->parent = NULL; owner->nextchild = NULL; } }
void ResourceOwnerRelease | ( | ResourceOwner | owner, | |
ResourceReleasePhase | phase, | |||
bool | isCommit, | |||
bool | isTopLevel | |||
) |
Definition at line 195 of file resowner.c.
References PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, and ResourceOwnerReleaseInternal().
Referenced by AbortSubTransaction(), AbortTransaction(), BackgroundWriterMain(), CheckpointerMain(), CommitSubTransaction(), CommitTransaction(), PortalDrop(), PrepareTransaction(), and WalWriterMain().
{ /* Rather than PG_TRY at every level of recursion, set it up once */ ResourceOwner save; save = CurrentResourceOwner; PG_TRY(); { ResourceOwnerReleaseInternal(owner, phase, isCommit, isTopLevel); } PG_CATCH(); { CurrentResourceOwner = save; PG_RE_THROW(); } PG_END_TRY(); CurrentResourceOwner = save; }
void UnregisterResourceReleaseCallback | ( | ResourceReleaseCallback | callback, | |
void * | arg | |||
) |
Definition at line 520 of file resowner.c.
References ResourceReleaseCallbackItem::next, and pfree().
{ ResourceReleaseCallbackItem *item; ResourceReleaseCallbackItem *prev; prev = NULL; for (item = ResourceRelease_callbacks; item; prev = item, item = item->next) { if (item->callback == callback && item->arg == arg) { if (prev) prev->next = item->next; else ResourceRelease_callbacks = item->next; pfree(item); break; } } }
PGDLLIMPORT ResourceOwner CurrentResourceOwner |
Definition at line 108 of file resowner.c.
Referenced by _hash_regscan(), AssignTransactionId(), AtAbort_ResourceOwner(), AtStart_ResourceOwner(), AtSubAbort_ResourceOwner(), AtSubStart_ResourceOwner(), BackgroundWriterMain(), BgBufferSync(), BufferSync(), CheckpointerMain(), CleanupSubTransaction(), CleanupTransaction(), close_lo_relation(), CommitSubTransaction(), CommitTransaction(), DecrTupleDescRefCount(), exec_init_tuple_store(), exec_stmt_block(), FlushDatabaseBuffers(), FlushRelationBuffers(), GetCachedPlan(), IncrBufferRefCount(), IncrTupleDescRefCount(), InitWalSender(), LocalBufferAlloc(), LockAcquireExtended(), LockReassignCurrentOwner(), LockReassignOwner(), LockRelease(), open_lo_relation(), open_share_lock(), OpenTemporaryFile(), PersistHoldablePortal(), 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_SPI_execute(), pltcl_SPI_execute_plan(), pltcl_SPI_prepare(), pltcl_subtrans_abort(), pltcl_subtrans_commit(), 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(), ReadBuffer_common(), RegisterSnapshot(), RelationDecrementReferenceCount(), RelationIncrementReferenceCount(), ReleaseAndReadBuffer(), ReleaseBuffer(), ReleaseCachedPlan(), ReleaseCatCache(), ReleaseCatCacheList(), ReleaseLockIfHeld(), ReleaseResources_hash(), SearchCatCache(), SearchCatCacheList(), tuplestore_begin_common(), tuplestore_puttuple_common(), UnpinBuffer(), UnregisterSnapshot(), WalReceiverMain(), and WalWriterMain().
PGDLLIMPORT ResourceOwner CurTransactionResourceOwner |
Definition at line 109 of file resowner.c.
Referenced by AtStart_ResourceOwner(), AtSubStart_ResourceOwner(), CleanupSubTransaction(), CleanupTransaction(), CommitSubTransaction(), CommitTransaction(), CreatePortal(), PopTransaction(), and PrepareTransaction().
PGDLLIMPORT ResourceOwner TopTransactionResourceOwner |
Definition at line 110 of file resowner.c.
Referenced by AbortTransaction(), AtAbort_ResourceOwner(), AtStart_ResourceOwner(), CleanupTransaction(), close_lo_relation(), CommitTransaction(), inv_close(), inv_open(), open_lo_relation(), open_share_lock(), PortalRun(), and PrepareTransaction().