PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/parallel.h"
#include "access/visibilitymap.h"
#include "access/xact.h"
#include "access/xlog.h"
#include "access/xloginsert.h"
#include "access/xlogutils.h"
#include "catalog/storage.h"
#include "catalog/storage_xlog.h"
#include "miscadmin.h"
#include "storage/freespace.h"
#include "storage/smgr.h"
#include "utils/hsearch.h"
#include "utils/memutils.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | PendingRelDelete |
struct | PendingRelSync |
Typedefs | |
typedef struct PendingRelDelete | PendingRelDelete |
typedef struct PendingRelSync | PendingRelSync |
Functions | |
static void | AddPendingSync (const RelFileNode *rnode) |
SMgrRelation | RelationCreateStorage (RelFileNode rnode, char relpersistence) |
void | log_smgrcreate (const RelFileNode *rnode, ForkNumber forkNum) |
void | RelationDropStorage (Relation rel) |
void | RelationPreserveStorage (RelFileNode rnode, bool atCommit) |
void | RelationTruncate (Relation rel, BlockNumber nblocks) |
void | RelationPreTruncate (Relation rel) |
void | RelationCopyStorage (SMgrRelation src, SMgrRelation dst, ForkNumber forkNum, char relpersistence) |
bool | RelFileNodeSkippingWAL (RelFileNode rnode) |
Size | EstimatePendingSyncsSpace (void) |
void | SerializePendingSyncs (Size maxSize, char *startAddress) |
void | RestorePendingSyncs (char *startAddress) |
void | smgrDoPendingDeletes (bool isCommit) |
void | smgrDoPendingSyncs (bool isCommit, bool isParallelWorker) |
int | smgrGetPendingDeletes (bool forCommit, RelFileNode **ptr) |
void | PostPrepare_smgr (void) |
void | AtSubCommit_smgr (void) |
void | AtSubAbort_smgr (void) |
void | smgr_redo (XLogReaderState *record) |
Variables | |
int | wal_skip_threshold = 2048 |
static PendingRelDelete * | pendingDeletes = NULL |
HTAB * | pendingSyncHash = NULL |
typedef struct PendingRelDelete PendingRelDelete |
typedef struct PendingRelSync PendingRelSync |
|
static |
Definition at line 84 of file storage.c.
References Assert, HASHCTL::entrysize, HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), HASHCTL::hcxt, PendingRelSync::is_truncated, HASHCTL::keysize, and TopTransactionContext.
Referenced by RelationCreateStorage(), and RestorePendingSyncs().
void AtSubAbort_smgr | ( | void | ) |
Definition at line 898 of file storage.c.
References smgrDoPendingDeletes().
Referenced by AbortSubTransaction().
void AtSubCommit_smgr | ( | void | ) |
Definition at line 878 of file storage.c.
References GetCurrentTransactionNestLevel(), PendingRelDelete::nestLevel, and PendingRelDelete::next.
Referenced by CommitSubTransaction().
Size EstimatePendingSyncsSpace | ( | void | ) |
Definition at line 511 of file storage.c.
References hash_get_num_entries(), and mul_size().
Referenced by InitializeParallelDSM().
void log_smgrcreate | ( | const RelFileNode * | rnode, |
ForkNumber | forkNum | ||
) |
Definition at line 175 of file storage.c.
References xl_smgr_create::forkNum, xl_smgr_create::rnode, XLOG_SMGR_CREATE, XLogBeginInsert(), XLogInsert(), XLogRegisterData(), and XLR_SPECIAL_REL_UPDATE.
Referenced by heapam_relation_copy_data(), heapam_relation_set_new_filenode(), index_copy_data(), and RelationCreateStorage().
void PostPrepare_smgr | ( | void | ) |
Definition at line 857 of file storage.c.
References PendingRelDelete::next, and pfree().
Referenced by PrepareTransaction().
void RelationCopyStorage | ( | SMgrRelation | src, |
SMgrRelation | dst, | ||
ForkNumber | forkNum, | ||
char | relpersistence | ||
) |
Definition at line 408 of file storage.c.
References RelFileNodeBackend::backend, buf, CHECK_FOR_INTERRUPTS, PGAlignedBlock::data, ereport, errcode(), ERRCODE_DATA_CORRUPTED, errmsg(), ERROR, INIT_FORKNUM, log_newpage(), RelFileNodeBackend::node, PageIsVerifiedExtended(), PageSetChecksumInplace(), PIV_LOG_WARNING, PIV_REPORT_STAT, relpathbackend, SMgrRelationData::smgr_rnode, smgrextend(), smgrimmedsync(), smgrnblocks(), smgrread(), and XLogIsNeeded.
Referenced by heapam_relation_copy_data(), and index_copy_data().
SMgrRelation RelationCreateStorage | ( | RelFileNode | rnode, |
char | relpersistence | ||
) |
Definition at line 118 of file storage.c.
References AddPendingSync(), Assert, PendingRelDelete::atCommit, PendingRelDelete::backend, BackendIdForTempRelations, elog, ERROR, GetCurrentTransactionNestLevel(), InvalidBackendId, IsInParallelMode(), log_smgrcreate(), MAIN_FORKNUM, MemoryContextAlloc(), PendingRelDelete::nestLevel, PendingRelDelete::next, RelFileNodeBackend::node, pendingDeletes, PendingRelDelete::relnode, SMgrRelationData::smgr_rnode, smgrcreate(), smgropen(), TopMemoryContext, and XLogIsNeeded.
Referenced by heap_create(), heapam_relation_copy_data(), heapam_relation_set_new_filenode(), index_copy_data(), and RelationSetNewRelfilenode().
void RelationDropStorage | ( | Relation | rel | ) |
Definition at line 195 of file storage.c.
References PendingRelDelete::atCommit, PendingRelDelete::backend, GetCurrentTransactionNestLevel(), MemoryContextAlloc(), PendingRelDelete::nestLevel, PendingRelDelete::next, pendingDeletes, RelationData::rd_backend, RelationData::rd_node, RelationCloseSmgr, PendingRelDelete::relnode, and TopMemoryContext.
Referenced by DefineQueryRewrite(), heap_drop_with_catalog(), heapam_relation_copy_data(), index_copy_data(), index_drop(), reindex_index(), and RelationSetNewRelfilenode().
void RelationPreserveStorage | ( | RelFileNode | rnode, |
bool | atCommit | ||
) |
Definition at line 240 of file storage.c.
References PendingRelDelete::atCommit, PendingRelDelete::next, pfree(), RelFileNodeEquals, and PendingRelDelete::relnode.
Referenced by ATExecAddIndex(), and write_relmap_file().
void RelationPreTruncate | ( | Relation | rel | ) |
Definition at line 386 of file storage.c.
References HASH_FIND, hash_search(), PendingRelSync::is_truncated, RelFileNodeBackend::node, RelationData::rd_smgr, RelationOpenSmgr, and SMgrRelationData::smgr_rnode.
Referenced by RelationTruncate().
void RelationTruncate | ( | Relation | rel, |
BlockNumber | nblocks | ||
) |
Definition at line 277 of file storage.c.
References xl_smgr_truncate::blkno, BlockNumberIsValid, blocks, xl_smgr_truncate::flags, FreeSpaceMapPrepareTruncateRel(), FreeSpaceMapVacuumRange(), FSM_FORKNUM, i, InvalidBlockNumber, MAIN_FORKNUM, MAX_FORKNUM, RelationData::rd_node, RelationData::rd_smgr, RelationNeedsWAL, RelationOpenSmgr, RelationPreTruncate(), xl_smgr_truncate::rnode, SMgrRelationData::smgr_cached_nblocks, SMgrRelationData::smgr_targblock, SMGR_TRUNCATE_ALL, smgrexists(), smgrtruncate(), VISIBILITYMAP_FORKNUM, visibilitymap_prepare_truncate(), XLOG_SMGR_TRUNCATE, XLogBeginInsert(), XLogFlush(), XLogInsert(), XLogRegisterData(), and XLR_SPECIAL_REL_UPDATE.
Referenced by heapam_relation_nontransactional_truncate(), lazy_truncate_heap(), RelationTruncateIndexes(), and spgvacuumscan().
bool RelFileNodeSkippingWAL | ( | RelFileNode | rnode | ) |
Definition at line 497 of file storage.c.
References HASH_FIND, and hash_search().
Referenced by MarkBufferDirtyHint(), RelationInitPhysicalAddr(), and RememberToFreeTupleDescAtEOX().
void RestorePendingSyncs | ( | char * | startAddress | ) |
Definition at line 575 of file storage.c.
References AddPendingSync(), Assert, and RelFileNode::relNode.
Referenced by ParallelWorkerMain().
void SerializePendingSyncs | ( | Size | maxSize, |
char * | startAddress | ||
) |
Definition at line 524 of file storage.c.
References CurrentMemoryContext, generate_unaccent_rules::dest, HASHCTL::entrysize, HASH_BLOBS, HASH_CONTEXT, hash_create(), hash_destroy(), HASH_ELEM, HASH_ENTER, hash_get_num_entries(), HASH_REMOVE, hash_search(), hash_seq_init(), hash_seq_search(), HASHCTL::hcxt, HASHCTL::keysize, MemSet, PendingRelDelete::next, and PendingRelSync::rnode.
Referenced by InitializeParallelDSM().
void smgr_redo | ( | XLogReaderState * | record | ) |
Definition at line 904 of file storage.c.
References Assert, xl_smgr_truncate::blkno, BlockNumberIsValid, blocks, CreateFakeRelcacheEntry(), elog, XLogReaderState::EndRecPtr, xl_smgr_truncate::flags, xl_smgr_create::forkNum, FreeFakeRelcacheEntry(), FreeSpaceMapPrepareTruncateRel(), FreeSpaceMapVacuumRange(), FSM_FORKNUM, InvalidBackendId, InvalidBlockNumber, MAIN_FORKNUM, MAX_FORKNUM, PANIC, xl_smgr_create::rnode, xl_smgr_truncate::rnode, SMGR_TRUNCATE_FSM, SMGR_TRUNCATE_HEAP, SMGR_TRUNCATE_VM, smgrcreate(), smgrexists(), smgropen(), smgrtruncate(), VISIBILITYMAP_FORKNUM, visibilitymap_prepare_truncate(), XLOG_SMGR_CREATE, XLOG_SMGR_TRUNCATE, XLogFlush(), XLogRecGetData, XLogRecGetInfo, XLogRecHasAnyBlockRefs, XLogTruncateRelation(), and XLR_INFO_MASK.
void smgrDoPendingDeletes | ( | bool | isCommit | ) |
Definition at line 596 of file storage.c.
References PendingRelDelete::atCommit, PendingRelDelete::backend, GetCurrentTransactionNestLevel(), i, PendingRelDelete::nestLevel, PendingRelDelete::next, palloc(), pfree(), PendingRelDelete::relnode, repalloc(), smgrclose(), smgrdounlinkall(), and smgropen().
Referenced by AbortTransaction(), AtSubAbort_smgr(), and CommitTransaction().
Definition at line 664 of file storage.c.
References Assert, AssertPendingSyncs_RelationCache, PendingRelDelete::atCommit, BlockNumberIsValid, CreateFakeRelcacheEntry(), FreeFakeRelcacheEntry(), GetCurrentTransactionNestLevel(), HASH_REMOVE, hash_search(), hash_seq_init(), hash_seq_search(), INIT_FORKNUM, InvalidBackendId, InvalidBlockNumber, PendingRelSync::is_truncated, log_newpage_range(), MAX_FORKNUM, PendingRelDelete::next, RelFileNodeBackend::node, palloc(), pfree(), PendingRelDelete::relnode, repalloc(), PendingRelSync::rnode, SMgrRelationData::smgr_rnode, smgrdosyncall(), smgrexists(), smgrnblocks(), smgropen(), and wal_skip_threshold.
Referenced by AbortTransaction(), CommitTransaction(), and PrepareTransaction().
int smgrGetPendingDeletes | ( | bool | forCommit, |
RelFileNode ** | ptr | ||
) |
Definition at line 816 of file storage.c.
References PendingRelDelete::atCommit, PendingRelDelete::backend, GetCurrentTransactionNestLevel(), InvalidBackendId, PendingRelDelete::nestLevel, PendingRelDelete::next, palloc(), and PendingRelDelete::relnode.
Referenced by RecordTransactionAbort(), RecordTransactionCommit(), and StartPrepare().
|
static |
Definition at line 75 of file storage.c.
Referenced by RelationCreateStorage(), and RelationDropStorage().
int wal_skip_threshold = 2048 |
Definition at line 38 of file storage.c.
Referenced by smgrDoPendingSyncs().