PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/parallel.h"
#include "catalog/catalog.h"
#include "executor/instrument.h"
#include "pgstat.h"
#include "storage/buf_internals.h"
#include "storage/bufmgr.h"
#include "utils/guc_hooks.h"
#include "utils/memutils.h"
#include "utils/resowner_private.h"
Go to the source code of this file.
Data Structures | |
struct | LocalBufferLookupEnt |
Macros | |
#define | LocalBufHdrGetBlock(bufHdr) LocalBufferBlockPointers[-((bufHdr)->buf_id + 2)] |
Functions | |
static void | InitLocalBuffers (void) |
static Block | GetLocalBufferStorage (void) |
PrefetchBufferResult | PrefetchLocalBuffer (SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum) |
BufferDesc * | LocalBufferAlloc (SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum, bool *foundPtr) |
void | MarkLocalBufferDirty (Buffer buffer) |
void | DropRelationLocalBuffers (RelFileLocator rlocator, ForkNumber forkNum, BlockNumber firstDelBlock) |
void | DropRelationAllLocalBuffers (RelFileLocator rlocator) |
bool | check_temp_buffers (int *newval, void **extra, GucSource source) |
static void | CheckForLocalBufferLeaks (void) |
void | AtEOXact_LocalBuffers (bool isCommit) |
void | AtProcExit_LocalBuffers (void) |
Variables | |
int | NLocBuffer = 0 |
BufferDesc * | LocalBufferDescriptors = NULL |
Block * | LocalBufferBlockPointers = NULL |
int32 * | LocalRefCount = NULL |
static int | nextFreeLocalBuf = 0 |
static HTAB * | LocalBufHash = NULL |
#define LocalBufHdrGetBlock | ( | bufHdr | ) | LocalBufferBlockPointers[-((bufHdr)->buf_id + 2)] |
Definition at line 39 of file localbuf.c.
void AtEOXact_LocalBuffers | ( | bool | isCommit | ) |
Definition at line 599 of file localbuf.c.
References CheckForLocalBufferLeaks().
Referenced by AtEOXact_Buffers().
void AtProcExit_LocalBuffers | ( | void | ) |
Definition at line 610 of file localbuf.c.
References CheckForLocalBufferLeaks().
Referenced by AtProcExit_Buffers().
Definition at line 491 of file localbuf.c.
References GUC_check_errdetail, newval, NLocBuffer, PGC_S_TEST, and source.
|
static |
Definition at line 570 of file localbuf.c.
References Assert(), b, i, LocalRefCount, NLocBuffer, and PrintBufferLeakWarning().
Referenced by AtEOXact_LocalBuffers(), and AtProcExit_LocalBuffers().
void DropRelationAllLocalBuffers | ( | RelFileLocator | rlocator | ) |
Definition at line 377 of file localbuf.c.
References buftag::blockNum, BM_TAG_VALID, BUF_FLAG_MASK, BUF_USAGECOUNT_MASK, BufTagGetForkNum(), BufTagGetRelFileLocator(), BufTagMatchesRelFileLocator(), ClearBufferTag(), elog(), ERROR, GetLocalBufferDescriptor(), HASH_REMOVE, hash_search(), i, LocalBufHash, LocalRefCount, MyBackendId, NLocBuffer, pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), relpathbackend, BufferDesc::state, and BufferDesc::tag.
Referenced by DropRelationsAllBuffers().
void DropRelationLocalBuffers | ( | RelFileLocator | rlocator, |
ForkNumber | forkNum, | ||
BlockNumber | firstDelBlock | ||
) |
Definition at line 329 of file localbuf.c.
References buftag::blockNum, BM_TAG_VALID, BUF_FLAG_MASK, BUF_USAGECOUNT_MASK, BufTagGetForkNum(), BufTagGetRelFileLocator(), BufTagMatchesRelFileLocator(), ClearBufferTag(), elog(), ERROR, GetLocalBufferDescriptor(), HASH_REMOVE, hash_search(), i, LocalBufHash, LocalRefCount, MyBackendId, NLocBuffer, pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), relpathbackend, BufferDesc::state, and BufferDesc::tag.
Referenced by DropRelationBuffers().
|
static |
Definition at line 515 of file localbuf.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), Max, MaxAllocSize, MemoryContextAlloc(), Min, NLocBuffer, and TopMemoryContext.
Referenced by LocalBufferAlloc().
|
static |
Definition at line 420 of file localbuf.c.
References buf, calloc, elog(), HASHCTL::entrysize, ereport, errcode(), errmsg(), ERROR, FATAL, GetLocalBufferDescriptor(), HASH_BLOBS, hash_create(), HASH_ELEM, i, IsParallelWorker, HASHCTL::keysize, LocalBufferBlockPointers, LocalBufferDescriptors, LocalBufHash, LocalRefCount, nextFreeLocalBuf, NLocBuffer, and num_temp_buffers.
Referenced by LocalBufferAlloc(), and PrefetchLocalBuffer().
BufferDesc* LocalBufferAlloc | ( | SMgrRelation | smgr, |
ForkNumber | forkNum, | ||
BlockNumber | blockNum, | ||
bool * | foundPtr | ||
) |
Definition at line 110 of file localbuf.c.
References Assert(), b, buftag::blockNum, BM_DIRTY, BM_IO_ERROR, BM_JUST_DIRTIED, BM_MAX_USAGE_COUNT, BM_TAG_VALID, BM_VALID, BUF_STATE_GET_USAGECOUNT, BUF_USAGECOUNT_MASK, BUF_USAGECOUNT_ONE, BufferDescriptorGetBuffer(), BufferTagsEqual(), BufTagGetForkNum(), BufTagGetRelFileLocator(), ClearBufferTag(), CurrentResourceOwner, elog(), ereport, errcode(), errmsg(), ERROR, fprintf, GetLocalBufferDescriptor(), GetLocalBufferStorage(), HASH_ENTER, HASH_FIND, HASH_REMOVE, hash_search(), LocalBufferLookupEnt::id, InitBufferTag(), InitLocalBuffers(), IOCONTEXT_NORMAL, IOOBJECT_TEMP_RELATION, IOOP_EVICT, IOOP_WRITE, BufferUsage::local_blks_written, LocalBufHash, LocalBufHdrGetBlock, LocalRefCount, RelFileLocatorBackend::locator, MyBackendId, nextFreeLocalBuf, NLocBuffer, PageSetChecksumInplace(), pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), pgBufferUsage, pgstat_count_io_op(), RelFileLocator::relNumber, ResourceOwnerRememberBuffer(), SMgrRelationData::smgr_rlocator, smgropen(), smgrwrite(), BufferDesc::state, and BufferDesc::tag.
Referenced by ReadBuffer_common().
void MarkLocalBufferDirty | ( | Buffer | buffer | ) |
Definition at line 289 of file localbuf.c.
References Assert(), BM_DIRTY, BufferIsLocal, fprintf, GetLocalBufferDescriptor(), BufferUsage::local_blks_dirtied, LocalRefCount, pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), pgBufferUsage, and BufferDesc::state.
Referenced by MarkBufferDirty(), and MarkBufferDirtyHint().
PrefetchBufferResult PrefetchLocalBuffer | ( | SMgrRelation | smgr, |
ForkNumber | forkNum, | ||
BlockNumber | blockNum | ||
) |
Definition at line 65 of file localbuf.c.
References HASH_FIND, hash_search(), LocalBufferLookupEnt::id, InitBufferTag(), PrefetchBufferResult::initiated_io, InitLocalBuffers(), InvalidBuffer, LocalBufHash, RelFileLocatorBackend::locator, PrefetchBufferResult::recent_buffer, SMgrRelationData::smgr_rlocator, and smgrprefetch().
Referenced by PrefetchBuffer().
Block* LocalBufferBlockPointers = NULL |
Definition at line 45 of file localbuf.c.
Referenced by BufferGetBlock(), and InitLocalBuffers().
BufferDesc* LocalBufferDescriptors = NULL |
Definition at line 44 of file localbuf.c.
Referenced by GetLocalBufferDescriptor(), and InitLocalBuffers().
|
static |
Definition at line 50 of file localbuf.c.
Referenced by DropRelationAllLocalBuffers(), DropRelationLocalBuffers(), InitLocalBuffers(), LocalBufferAlloc(), and PrefetchLocalBuffer().
int32* LocalRefCount = NULL |
Definition at line 46 of file localbuf.c.
Referenced by CheckForLocalBufferLeaks(), ConditionalLockBufferForCleanup(), DropRelationAllLocalBuffers(), DropRelationLocalBuffers(), IncrBufferRefCount(), InitLocalBuffers(), IsBufferCleanupOK(), LocalBufferAlloc(), LockBufferForCleanup(), MarkLocalBufferDirty(), PrintBufferLeakWarning(), ReadRecentBuffer(), ReleaseAndReadBuffer(), and ReleaseBuffer().
|
static |
Definition at line 48 of file localbuf.c.
Referenced by InitLocalBuffers(), and LocalBufferAlloc().
int NLocBuffer = 0 |
Definition at line 42 of file localbuf.c.
Referenced by BufferIsValid(), check_temp_buffers(), CheckForLocalBufferLeaks(), DropRelationAllLocalBuffers(), DropRelationLocalBuffers(), FlushRelationBuffers(), GetLocalBufferStorage(), hashbuild(), InitLocalBuffers(), and LocalBufferAlloc().