PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/parallel.h"
#include "catalog/catalog.h"
#include "executor/instrument.h"
#include "storage/buf_internals.h"
#include "storage/bufmgr.h"
#include "utils/guc.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 | DropRelFileNodeLocalBuffers (RelFileNode rnode, ForkNumber forkNum, BlockNumber firstDelBlock) |
void | DropRelFileNodeAllLocalBuffers (RelFileNode rnode) |
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 38 of file localbuf.c.
void AtEOXact_LocalBuffers | ( | bool | isCommit | ) |
Definition at line 577 of file localbuf.c.
References CheckForLocalBufferLeaks().
Referenced by AtEOXact_Buffers().
void AtProcExit_LocalBuffers | ( | void | ) |
Definition at line 588 of file localbuf.c.
References CheckForLocalBufferLeaks().
Referenced by AtProcExit_Buffers().
|
static |
Definition at line 548 of file localbuf.c.
References Assert(), b, i, LocalRefCount, NLocBuffer, and PrintBufferLeakWarning().
Referenced by AtEOXact_LocalBuffers(), and AtProcExit_LocalBuffers().
void DropRelFileNodeAllLocalBuffers | ( | RelFileNode | rnode | ) |
Definition at line 373 of file localbuf.c.
References buftag::blockNum, BM_TAG_VALID, BUF_FLAG_MASK, BUF_USAGECOUNT_MASK, CLEAR_BUFFERTAG, elog, ERROR, buftag::forkNum, GetLocalBufferDescriptor, HASH_REMOVE, hash_search(), i, LocalBufHash, LocalRefCount, MyBackendId, NLocBuffer, pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), RelFileNodeEquals, relpathbackend, buftag::rnode, BufferDesc::state, and BufferDesc::tag.
Referenced by DropRelFileNodesAllBuffers().
void DropRelFileNodeLocalBuffers | ( | RelFileNode | rnode, |
ForkNumber | forkNum, | ||
BlockNumber | firstDelBlock | ||
) |
Definition at line 326 of file localbuf.c.
References buftag::blockNum, BM_TAG_VALID, BUF_FLAG_MASK, BUF_USAGECOUNT_MASK, CLEAR_BUFFERTAG, elog, ERROR, buftag::forkNum, GetLocalBufferDescriptor, HASH_REMOVE, hash_search(), i, LocalBufHash, LocalRefCount, MyBackendId, NLocBuffer, pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), RelFileNodeEquals, relpathbackend, buftag::rnode, BufferDesc::state, and BufferDesc::tag.
Referenced by DropRelFileNodeBuffers().
|
static |
Definition at line 493 of file localbuf.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), Max, MaxAllocSize, MemoryContextAlloc(), Min, NLocBuffer, and TopMemoryContext.
Referenced by LocalBufferAlloc().
|
static |
Definition at line 416 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 109 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, BUFFERTAGS_EQUAL, CLEAR_BUFFERTAG, CurrentResourceOwner, elog, ereport, errcode(), errmsg(), ERROR, buftag::forkNum, fprintf, GetLocalBufferDescriptor, GetLocalBufferStorage(), HASH_ENTER, HASH_FIND, HASH_REMOVE, hash_search(), LocalBufferLookupEnt::id, INIT_BUFFERTAG, InitLocalBuffers(), BufferUsage::local_blks_written, LocalBufHash, LocalBufHdrGetBlock, LocalRefCount, MyBackendId, nextFreeLocalBuf, NLocBuffer, RelFileNodeBackend::node, PageSetChecksumInplace(), pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), pgBufferUsage, RelFileNode::relNode, ResourceOwnerRememberBuffer(), buftag::rnode, SMgrRelationData::smgr_rnode, smgropen(), smgrwrite(), BufferDesc::state, and BufferDesc::tag.
Referenced by ReadBuffer_common().
void MarkLocalBufferDirty | ( | Buffer | buffer | ) |
Definition at line 286 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 64 of file localbuf.c.
References HASH_FIND, hash_search(), LocalBufferLookupEnt::id, INIT_BUFFERTAG, PrefetchBufferResult::initiated_io, InitLocalBuffers(), InvalidBuffer, LocalBufHash, RelFileNodeBackend::node, PrefetchBufferResult::recent_buffer, SMgrRelationData::smgr_rnode, and smgrprefetch().
Referenced by PrefetchBuffer().
Block* LocalBufferBlockPointers = NULL |
Definition at line 44 of file localbuf.c.
Referenced by InitLocalBuffers().
BufferDesc* LocalBufferDescriptors = NULL |
Definition at line 43 of file localbuf.c.
Referenced by InitLocalBuffers().
|
static |
Definition at line 49 of file localbuf.c.
Referenced by DropRelFileNodeAllLocalBuffers(), DropRelFileNodeLocalBuffers(), InitLocalBuffers(), LocalBufferAlloc(), and PrefetchLocalBuffer().
int32* LocalRefCount = NULL |
Definition at line 45 of file localbuf.c.
Referenced by CheckForLocalBufferLeaks(), ConditionalLockBufferForCleanup(), DropRelFileNodeAllLocalBuffers(), DropRelFileNodeLocalBuffers(), IncrBufferRefCount(), InitLocalBuffers(), IsBufferCleanupOK(), LocalBufferAlloc(), LockBufferForCleanup(), MarkLocalBufferDirty(), PrintBufferLeakWarning(), ReadRecentBuffer(), ReleaseAndReadBuffer(), and ReleaseBuffer().
|
static |
Definition at line 47 of file localbuf.c.
Referenced by InitLocalBuffers(), and LocalBufferAlloc().
int NLocBuffer = 0 |
Definition at line 41 of file localbuf.c.
Referenced by check_temp_buffers(), CheckForLocalBufferLeaks(), DropRelFileNodeAllLocalBuffers(), DropRelFileNodeLocalBuffers(), FlushRelationBuffers(), GetLocalBufferStorage(), hashbuild(), InitLocalBuffers(), and LocalBufferAlloc().