PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "common/hashfn.h"
#include "common/int.h"
#include "storage/ipc.h"
#include "storage/predicate.h"
#include "storage/proc.h"
#include "utils/memutils.h"
#include "utils/resowner.h"
Go to the source code of this file.
Data Structures | |
struct | ResourceElem |
struct | ResourceOwnerData |
struct | ResourceReleaseCallbackItem |
Macros | |
#define | RESOWNER_ARRAY_SIZE 32 |
#define | RESOWNER_HASH_INIT_SIZE 64 |
#define | RESOWNER_HASH_MAX_ITEMS(capacity) Min(capacity - RESOWNER_ARRAY_SIZE, (capacity)/4 * 3) |
#define | MAX_RESOWNER_LOCKS 15 |
Typedefs | |
typedef struct ResourceElem | ResourceElem |
typedef struct ResourceReleaseCallbackItem | ResourceReleaseCallbackItem |
Variables | |
ResourceOwner | CurrentResourceOwner = NULL |
ResourceOwner | CurTransactionResourceOwner = NULL |
ResourceOwner | TopTransactionResourceOwner = NULL |
ResourceOwner | AuxProcessResourceOwner = NULL |
static ResourceReleaseCallbackItem * | ResourceRelease_callbacks = NULL |
#define MAX_RESOWNER_LOCKS 15 |
Definition at line 105 of file resowner.c.
#define RESOWNER_ARRAY_SIZE 32 |
Definition at line 71 of file resowner.c.
#define RESOWNER_HASH_INIT_SIZE 64 |
Definition at line 77 of file resowner.c.
#define RESOWNER_HASH_MAX_ITEMS | ( | capacity | ) | Min(capacity - RESOWNER_ARRAY_SIZE, (capacity)/4 * 3) |
Definition at line 89 of file resowner.c.
typedef struct ResourceElem ResourceElem |
typedef struct ResourceReleaseCallbackItem ResourceReleaseCallbackItem |
void CreateAuxProcessResourceOwner | ( | void | ) |
Definition at line 982 of file resowner.c.
References Assert, AuxProcessResourceOwner, CurrentResourceOwner, on_shmem_exit(), ReleaseAuxProcessResourcesCallback(), and ResourceOwnerCreate().
Referenced by AuxiliaryProcessMainCommon(), and InitPostgres().
|
inlinestatic |
Definition at line 214 of file resowner.c.
References hash_combine(), hash_combine64(), murmurhash32(), murmurhash64(), and value.
Referenced by ResourceOwnerAddToHash(), and ResourceOwnerForget().
void RegisterResourceReleaseCallback | ( | ResourceReleaseCallback | callback, |
void * | arg | ||
) |
Definition at line 944 of file resowner.c.
References ResourceReleaseCallbackItem::arg, arg, ResourceReleaseCallbackItem::callback, callback(), MemoryContextAlloc(), ResourceReleaseCallbackItem::next, ResourceRelease_callbacks, and TopMemoryContext.
void ReleaseAuxProcessResources | ( | bool | isCommit | ) |
Definition at line 1002 of file resowner.c.
References AuxProcessResourceOwner, ResourceOwnerData::releasing, RESOURCE_RELEASE_AFTER_LOCKS, RESOURCE_RELEASE_BEFORE_LOCKS, RESOURCE_RELEASE_LOCKS, ResourceOwnerRelease(), and ResourceOwnerData::sorted.
Referenced by BackgroundWriterMain(), CheckpointerMain(), InitPostgres(), perform_base_backup(), pgarch_archiveXlog(), ReleaseAuxProcessResourcesCallback(), UploadManifest(), WalSndErrorCleanup(), WalSummarizerMain(), and WalWriterMain().
|
static |
Definition at line 1027 of file resowner.c.
References ReleaseAuxProcessResources().
Referenced by CreateAuxProcessResourceOwner().
|
static |
Definition at line 261 of file resowner.c.
References a, b, ResourceElem::kind, pg_cmp_u32(), ResourceOwnerDesc::release_phase, and ResourceOwnerDesc::release_priority.
Referenced by ResourceOwnerSort().
|
static |
Definition at line 237 of file resowner.c.
References Assert, ResourceOwnerData::capacity, ResourceOwnerData::hash, hash_resource_elem(), idx(), ResourceElem::item, ResourceElem::kind, ResourceOwnerData::nhash, and value.
Referenced by ResourceOwnerEnlarge().
ResourceOwner ResourceOwnerCreate | ( | ResourceOwner | parent, |
const char * | name | ||
) |
Definition at line 413 of file resowner.c.
References ResourceOwnerData::firstchild, MemoryContextAllocZero(), name, ResourceOwnerData::name, ResourceOwnerData::nextchild, ResourceOwnerData::parent, and TopMemoryContext.
Referenced by AtStart_ResourceOwner(), AtSubStart_ResourceOwner(), CreateAuxProcessResourceOwner(), CreatePortal(), plpgsql_call_handler(), plpgsql_create_econtext(), plpgsql_inline_handler(), test_dsa_resowners(), test_resowner_forget_between_phases(), test_resowner_leak(), test_resowner_many(), test_resowner_priorities(), and test_resowner_remember_between_phases().
void ResourceOwnerDelete | ( | ResourceOwner | owner | ) |
Definition at line 854 of file resowner.c.
References Assert, CurrentResourceOwner, ResourceOwnerData::firstchild, ResourceOwnerData::hash, MAX_RESOWNER_LOCKS, ResourceOwnerData::narr, ResourceOwnerData::nhash, ResourceOwnerData::nlocks, pfree(), and ResourceOwnerNewParent().
Referenced by CleanupSubTransaction(), CleanupTransaction(), CommitSubTransaction(), CommitTransaction(), plpgsql_call_handler(), plpgsql_inline_handler(), PortalDrop(), PrepareTransaction(), test_dsa_resowners(), test_resowner_leak(), test_resowner_many(), and test_resowner_priorities().
void ResourceOwnerEnlarge | ( | ResourceOwner | owner | ) |
Definition at line 442 of file resowner.c.
References ResourceOwnerData::arr, Assert, ResourceOwnerData::capacity, elog, ERROR, ResourceOwnerData::grow_at, ResourceOwnerData::hash, i, ResourceElem::item, ResourceElem::kind, MemoryContextAllocZero(), ResourceOwnerData::narr, ResourceOwnerData::nhash, pfree(), ResourceOwnerData::releasing, ResourceOwnerAddToHash(), RESOWNER_ARRAY_SIZE, RESOWNER_HASH_INIT_SIZE, RESOWNER_HASH_MAX_ITEMS, and TopMemoryContext.
Referenced by BufferAlloc(), CachedPlanAllowsSimpleValidityCheck(), CachedPlanIsSimplyValid(), CreateWaitEventSet(), dsm_create_descriptor(), dsm_unpin_mapping(), EvictUnpinnedBuffer(), ExtendBufferedRelLocal(), ExtendBufferedRelShared(), FlushDatabaseBuffers(), FlushRelationBuffers(), FlushRelationsAllBuffers(), GetCachedPlan(), GetLocalVictimBuffer(), GetVictimBuffer(), IncrBufferRefCount(), IncrTupleDescRefCount(), llvm_create_context(), LocalBufferAlloc(), OpenTemporaryFile(), PathNameCreateTemporaryFile(), PathNameOpenTemporaryFile(), pg_cryptohash_create(), pg_hmac_create(), px_find_cipher(), px_find_digest(), ReadRecentBuffer(), RegisterSnapshotOnOwner(), RelationIncrementReferenceCount(), RememberManyTestResources(), SearchCatCacheInternal(), SearchCatCacheList(), SearchCatCacheMiss(), StartBufferIO(), SyncOneBuffer(), test_resowner_forget_between_phases(), test_resowner_leak(), test_resowner_priorities(), and test_resowner_remember_between_phases().
void ResourceOwnerForget | ( | ResourceOwner | owner, |
Datum | value, | ||
const ResourceOwnerDesc * | kind | ||
) |
Definition at line 554 of file resowner.c.
References ResourceOwnerData::arr, Assert, ResourceOwnerData::capacity, DatumGetPointer(), elog, ERROR, ResourceOwnerData::hash, hash_resource_elem(), i, idx(), ResourceElem::item, ResourceElem::kind, ResourceOwnerData::name, ResourceOwnerDesc::name, ResourceOwnerData::narr, ResourceOwnerData::nhash, ResourceOwnerData::releasing, ResourceOwnerData::sorted, and value.
Referenced by ForgetManyTestResources(), ResourceOwnerForgetBuffer(), ResourceOwnerForgetBufferIO(), ResourceOwnerForgetCatCacheListRef(), ResourceOwnerForgetCatCacheRef(), ResourceOwnerForgetCryptoHash(), ResourceOwnerForgetDSM(), ResourceOwnerForgetFile(), ResourceOwnerForgetHMAC(), ResourceOwnerForgetJIT(), ResourceOwnerForgetOSSLCipher(), ResourceOwnerForgetOSSLDigest(), ResourceOwnerForgetPlanCacheRef(), ResourceOwnerForgetRelationRef(), ResourceOwnerForgetSnapshot(), ResourceOwnerForgetTupleDesc(), ResourceOwnerForgetWaitEventSet(), and test_resowner_forget_between_phases().
void ResourceOwnerForgetLock | ( | ResourceOwner | owner, |
LOCALLOCK * | locallock | ||
) |
Definition at line 1065 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().
ResourceOwner ResourceOwnerGetParent | ( | ResourceOwner | owner | ) |
Definition at line 888 of file resowner.c.
References ResourceOwnerData::parent.
Referenced by LockReassignCurrentOwner().
void ResourceOwnerNewParent | ( | ResourceOwner | owner, |
ResourceOwner | newparent | ||
) |
Definition at line 897 of file resowner.c.
References Assert, ResourceOwnerData::firstchild, ResourceOwnerData::nextchild, and ResourceOwnerData::parent.
Referenced by AtSubAbort_Portals(), AtSubCommit_Portals(), and ResourceOwnerDelete().
void ResourceOwnerRelease | ( | ResourceOwner | owner, |
ResourceReleasePhase | phase, | ||
bool | isCommit, | ||
bool | isTopLevel | ||
) |
Definition at line 648 of file resowner.c.
References elog, LOG, and ResourceOwnerReleaseInternal().
Referenced by AbortSubTransaction(), AbortTransaction(), CommitSubTransaction(), CommitTransaction(), PortalDrop(), PrepareTransaction(), ReleaseAuxProcessResources(), test_dsa_resowners(), test_resowner_forget_between_phases(), test_resowner_leak(), test_resowner_many(), test_resowner_priorities(), and test_resowner_remember_between_phases().
|
static |
Definition at line 340 of file resowner.c.
References ResourceOwnerData::arr, Assert, DatumGetPointer(), ResourceOwnerDesc::DebugPrint, elog, ResourceOwnerData::hash, idx(), items, ResourceOwnerDesc::name, ResourceOwnerData::narr, ResourceOwnerData::nhash, nitems, pfree(), psprintf(), ResourceOwnerDesc::release_phase, ResourceOwnerDesc::ReleaseResource, ResourceOwnerData::releasing, ResourceOwnerData::sorted, value, and WARNING.
Referenced by ResourceOwnerReleaseInternal().
void ResourceOwnerReleaseAllOfKind | ( | ResourceOwner | owner, |
const ResourceOwnerDesc * | kind | ||
) |
Definition at line 801 of file resowner.c.
References ResourceOwnerData::arr, Assert, ResourceOwnerData::capacity, elog, ERROR, ResourceOwnerData::hash, i, ResourceElem::item, ResourceElem::kind, ResourceOwnerDesc::name, ResourceOwnerData::narr, ResourceOwnerData::nhash, ResourceOwnerDesc::ReleaseResource, ResourceOwnerData::releasing, ResourceOwnerData::sorted, and value.
Referenced by ReleaseAllPlanCacheRefsInOwner().
|
static |
Definition at line 668 of file resowner.c.
References ResourceReleaseCallbackItem::arg, Assert, ResourceReleaseCallbackItem::callback, CurrentResourceOwner, ResourceOwnerData::firstchild, LockReassignCurrentOwner(), LockReleaseCurrentOwner(), ResourceOwnerData::locks, MAX_RESOWNER_LOCKS, next, ResourceReleaseCallbackItem::next, ResourceOwnerData::nextchild, ResourceOwnerData::nlocks, ResourceOwnerData::parent, ProcReleaseLocks(), ReleasePredicateLocks(), ResourceOwnerData::releasing, RESOURCE_RELEASE_AFTER_LOCKS, RESOURCE_RELEASE_BEFORE_LOCKS, RESOURCE_RELEASE_LOCKS, ResourceOwnerReleaseAll(), ResourceOwnerSort(), ResourceRelease_callbacks, ResourceOwnerData::sorted, and TopTransactionResourceOwner.
Referenced by ResourceOwnerRelease().
void ResourceOwnerRemember | ( | ResourceOwner | owner, |
Datum | value, | ||
const ResourceOwnerDesc * | kind | ||
) |
Definition at line 514 of file resowner.c.
References ResourceOwnerData::arr, Assert, elog, ERROR, idx(), ResourceElem::item, ResourceElem::kind, ResourceOwnerData::narr, ResourceOwnerDesc::release_phase, ResourceOwnerDesc::release_priority, ResourceOwnerData::releasing, RESOWNER_ARRAY_SIZE, ResourceOwnerData::sorted, and value.
Referenced by RememberManyTestResources(), ResourceOwnerRememberBuffer(), ResourceOwnerRememberBufferIO(), ResourceOwnerRememberCatCacheListRef(), ResourceOwnerRememberCatCacheRef(), ResourceOwnerRememberCryptoHash(), ResourceOwnerRememberDSM(), ResourceOwnerRememberFile(), ResourceOwnerRememberHMAC(), ResourceOwnerRememberJIT(), ResourceOwnerRememberOSSLCipher(), ResourceOwnerRememberOSSLDigest(), ResourceOwnerRememberPlanCacheRef(), ResourceOwnerRememberRelationRef(), ResourceOwnerRememberSnapshot(), ResourceOwnerRememberTupleDesc(), ResourceOwnerRememberWaitEventSet(), test_resowner_forget_between_phases(), test_resowner_leak(), test_resowner_priorities(), and test_resowner_remember_between_phases().
void ResourceOwnerRememberLock | ( | ResourceOwner | owner, |
LOCALLOCK * | locallock | ||
) |
Definition at line 1045 of file resowner.c.
References Assert, ResourceOwnerData::locks, MAX_RESOWNER_LOCKS, and ResourceOwnerData::nlocks.
Referenced by GrantLockLocal(), and LockReassignOwner().
|
static |
Definition at line 284 of file resowner.c.
References ResourceOwnerData::arr, Assert, ResourceOwnerData::capacity, ResourceOwnerData::hash, idx(), items, ResourceElem::kind, ResourceOwnerData::narr, ResourceOwnerData::nhash, nitems, qsort, and resource_priority_cmp().
Referenced by ResourceOwnerReleaseInternal().
StaticAssertDecl | ( | RESOWNER_HASH_MAX_ITEMS(RESOWNER_HASH_INIT_SIZE) >= | RESOWNER_ARRAY_SIZE, |
"initial hash size too small compared to array size" | |||
) |
void UnregisterResourceReleaseCallback | ( | ResourceReleaseCallback | callback, |
void * | arg | ||
) |
Definition at line 958 of file resowner.c.
References ResourceReleaseCallbackItem::arg, arg, ResourceReleaseCallbackItem::callback, callback(), ResourceReleaseCallbackItem::next, pfree(), and ResourceRelease_callbacks.
ResourceOwner AuxProcessResourceOwner = NULL |
Definition at line 168 of file resowner.c.
Referenced by CreateAuxProcessResourceOwner(), perform_base_backup(), ReleaseAuxProcessResources(), ShutdownXLOG(), StartupXLOG(), and UploadManifest().
ResourceOwner CurrentResourceOwner = NULL |
Definition at line 165 of file resowner.c.
Referenced by _SPI_execute_plan(), apply_spooled_messages(), AssignTransactionId(), AtAbort_ResourceOwner(), AtStart_ResourceOwner(), AtSubAbort_ResourceOwner(), AtSubStart_ResourceOwner(), attach_internal(), BufferAlloc(), CleanupSubTransaction(), CleanupTransaction(), close_lo_relation(), CommitSubTransaction(), CommitTransaction(), create_internal(), CreateAuxProcessResourceOwner(), DecrTupleDescRefCount(), dsm_create_descriptor(), dsm_unpin_mapping(), EvictUnpinnedBuffer(), exec_eval_simple_expr(), exec_init_tuple_store(), exec_simple_check_plan(), exec_stmt_block(), ExecAppendAsyncEventWait(), ExplainExecuteQuery(), ExtendBufferedRelLocal(), ExtendBufferedRelShared(), extendBufFile(), FlushDatabaseBuffers(), FlushRelationBuffers(), FlushRelationsAllBuffers(), get_segment_by_index(), GetCurrentFDWTuplestore(), GetLocalVictimBuffer(), GetVictimBuffer(), IncrBufferRefCount(), IncrTupleDescRefCount(), InitPostgres(), llvm_create_context(), LocalBufferAlloc(), lock_and_open_sequence(), LockAcquireExtended(), LockReassignCurrentOwner(), LockReassignOwner(), LockRelease(), LogicalSlotAdvanceAndCheckSnapState(), make_callstmt_target(), make_new_segment(), makeBufFileCommon(), MakeTransitionCaptureState(), open_lo_relation(), OpenTemporaryFile(), PathNameCreateTemporaryFile(), PathNameOpenTemporaryFile(), perform_base_backup(), PersistHoldablePortal(), pg_cryptohash_create(), pg_hmac_create(), pg_logical_slot_get_changes_guts(), PinBuffer(), PinBuffer_Locked(), PinLocalBuffer(), 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(), ReadRecentBuffer(), RegisterSnapshot(), RegisterTemporaryFile(), RelationDecrementReferenceCount(), RelationIncrementReferenceCount(), ReleaseCatCache(), ReleaseCatCacheList(), ReleaseCatCacheListWithOwner(), ReleaseCatCacheWithOwner(), ReleaseLockIfHeld(), ResourceOwnerDelete(), ResourceOwnerReleaseInternal(), SearchCatCacheInternal(), SearchCatCacheList(), SearchCatCacheMiss(), ShutdownXLOG(), SnapBuildClearExportedSnapshot(), SnapBuildExportSnapshot(), SPI_plan_get_cached_plan(), StartBufferIO(), StartupXLOG(), SyncOneBuffer(), TerminateBufferIO(), test_dsa_resowners(), test_resowner_forget_between_phases(), test_resowner_leak(), test_resowner_many(), test_resowner_priorities(), test_resowner_remember_between_phases(), tuplestore_begin_common(), tuplestore_puttuple_common(), UnpinBuffer(), UnpinLocalBuffer(), UnregisterSnapshot(), UploadManifest(), and WaitLatchOrSocket().
ResourceOwner CurTransactionResourceOwner = NULL |
Definition at line 166 of file resowner.c.
Referenced by AtStart_ResourceOwner(), AtSubStart_ResourceOwner(), CleanupSubTransaction(), CleanupTransaction(), CommitSubTransaction(), CommitTransaction(), CreatePortal(), GetCurrentFDWTuplestore(), MakeTransitionCaptureState(), PopTransaction(), and PrepareTransaction().
|
static |
Definition at line 187 of file resowner.c.
Referenced by RegisterResourceReleaseCallback(), ResourceOwnerReleaseInternal(), and UnregisterResourceReleaseCallback().
ResourceOwner TopTransactionResourceOwner = NULL |
Definition at line 167 of file resowner.c.
Referenced by AbortTransaction(), apply_spooled_messages(), AtAbort_ResourceOwner(), AtStart_ResourceOwner(), be_lo_open(), CleanupTransaction(), close_lo_relation(), closeLOfd(), CommitTransaction(), lock_and_open_sequence(), open_lo_relation(), plpgsql_create_econtext(), PortalRun(), PrepareTransaction(), and ResourceOwnerReleaseInternal().