PostgreSQL Source Code
git master
|
#include "postgres.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/bulk_write.h"
#include "storage/freespace.h"
#include "storage/proc.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 |
Variables | |
int | wal_skip_threshold = 2048 |
static PendingRelDelete * | pendingDeletes = NULL |
static HTAB * | pendingSyncHash = NULL |
typedef struct PendingRelDelete PendingRelDelete |
typedef struct PendingRelSync PendingRelSync |
|
static |
Definition at line 85 of file storage.c.
References Assert, ctl, HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), PendingRelSync::is_truncated, pendingSyncHash, and TopTransactionContext.
Referenced by RelationCreateStorage(), and RestorePendingSyncs().
void AtSubAbort_smgr | ( | void | ) |
Definition at line 934 of file storage.c.
References smgrDoPendingDeletes().
Referenced by AbortSubTransaction().
void AtSubCommit_smgr | ( | void | ) |
Definition at line 914 of file storage.c.
References GetCurrentTransactionNestLevel(), PendingRelDelete::nestLevel, PendingRelDelete::next, and pendingDeletes.
Referenced by CommitSubTransaction().
Size EstimatePendingSyncsSpace | ( | void | ) |
Definition at line 546 of file storage.c.
References hash_get_num_entries(), mul_size(), and pendingSyncHash.
Referenced by InitializeParallelDSM().
void log_smgrcreate | ( | const RelFileLocator * | rlocator, |
ForkNumber | forkNum | ||
) |
Definition at line 186 of file storage.c.
References xl_smgr_create::forkNum, xl_smgr_create::rlocator, XLOG_SMGR_CREATE, XLogBeginInsert(), XLogInsert(), XLogRegisterData(), and XLR_SPECIAL_REL_UPDATE.
Referenced by CreateAndCopyRelationData(), fill_seq_with_data(), heapam_relation_copy_data(), heapam_relation_set_new_filelocator(), index_build(), index_copy_data(), and RelationCreateStorage().
void PostPrepare_smgr | ( | void | ) |
Definition at line 893 of file storage.c.
References next, PendingRelDelete::next, pendingDeletes, and pfree().
Referenced by PrepareTransaction().
void RelationCopyStorage | ( | SMgrRelation | src, |
SMgrRelation | dst, | ||
ForkNumber | forkNum, | ||
char | relpersistence | ||
) |
Definition at line 452 of file storage.c.
References RelFileLocatorBackend::backend, buf, CHECK_FOR_INTERRUPTS, ereport, errcode(), ERRCODE_DATA_CORRUPTED, errmsg(), ERROR, INIT_FORKNUM, RelFileLocatorBackend::locator, PageIsVerifiedExtended(), PIV_LOG_WARNING, PIV_REPORT_STAT, relpath, relpathbackend, smgr_bulk_finish(), smgr_bulk_get_buf(), smgr_bulk_start_smgr(), smgr_bulk_write(), SMgrRelationData::smgr_rlocator, smgrnblocks(), smgrread(), and XLogIsNeeded.
Referenced by heapam_relation_copy_data(), and index_copy_data().
SMgrRelation RelationCreateStorage | ( | RelFileLocator | rlocator, |
char | relpersistence, | ||
bool | register_delete | ||
) |
Definition at line 121 of file storage.c.
References AddPendingSync(), Assert, PendingRelDelete::atCommit, elog, ERROR, GetCurrentTransactionNestLevel(), INVALID_PROC_NUMBER, IsInParallelMode(), RelFileLocatorBackend::locator, log_smgrcreate(), MAIN_FORKNUM, MemoryContextAlloc(), PendingRelDelete::nestLevel, PendingRelDelete::next, pendingDeletes, PendingRelDelete::procNumber, ProcNumberForTempRelations, PendingRelDelete::rlocator, SMgrRelationData::smgr_rlocator, smgrcreate(), smgropen(), TopMemoryContext, and XLogIsNeeded.
Referenced by CreateAndCopyRelationData(), heap_create(), heapam_relation_copy_data(), heapam_relation_set_new_filelocator(), index_copy_data(), and RelationSetNewRelfilenumber().
void RelationDropStorage | ( | Relation | rel | ) |
Definition at line 206 of file storage.c.
References PendingRelDelete::atCommit, GetCurrentTransactionNestLevel(), MemoryContextAlloc(), PendingRelDelete::nestLevel, PendingRelDelete::next, pendingDeletes, PendingRelDelete::procNumber, RelationData::rd_backend, RelationData::rd_locator, RelationCloseSmgr(), PendingRelDelete::rlocator, and TopMemoryContext.
Referenced by heap_drop_with_catalog(), heapam_relation_copy_data(), index_copy_data(), index_drop(), reindex_index(), and RelationSetNewRelfilenumber().
void RelationPreserveStorage | ( | RelFileLocator | rlocator, |
bool | atCommit | ||
) |
Definition at line 251 of file storage.c.
References PendingRelDelete::atCommit, next, PendingRelDelete::next, pendingDeletes, pfree(), RelFileLocatorEquals, and PendingRelDelete::rlocator.
Referenced by ATExecAddIndex(), and write_relmap_file().
void RelationPreTruncate | ( | Relation | rel | ) |
Definition at line 424 of file storage.c.
References HASH_FIND, hash_search(), PendingRelSync::is_truncated, pendingSyncHash, and RelationGetSmgr().
Referenced by RelationTruncate().
void RelationTruncate | ( | Relation | rel, |
BlockNumber | nblocks | ||
) |
Definition at line 288 of file storage.c.
References Assert, xl_smgr_truncate::blkno, BlockNumberIsValid(), DELAY_CHKPT_COMPLETE, PGPROC::delayChkptFlags, xl_smgr_truncate::flags, FreeSpaceMapPrepareTruncateRel(), FreeSpaceMapVacuumRange(), FSM_FORKNUM, i, InvalidBlockNumber, MAIN_FORKNUM, MAX_FORKNUM, MyProc, RelationData::rd_locator, RelationGetSmgr(), RelationNeedsWAL, RelationPreTruncate(), xl_smgr_truncate::rlocator, 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 RelFileLocatorSkippingWAL | ( | RelFileLocator | rlocator | ) |
Definition at line 532 of file storage.c.
References HASH_FIND, hash_search(), and pendingSyncHash.
Referenced by MarkBufferDirtyHint(), and RelationInitPhysicalAddr().
void RestorePendingSyncs | ( | char * | startAddress | ) |
Definition at line 610 of file storage.c.
References AddPendingSync(), Assert, pendingSyncHash, and RelFileLocator::relNumber.
Referenced by ParallelWorkerMain().
void SerializePendingSyncs | ( | Size | maxSize, |
char * | startAddress | ||
) |
Definition at line 559 of file storage.c.
References ctl, CurrentMemoryContext, generate_unaccent_rules::dest, 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(), MemSet, PendingRelDelete::next, pendingDeletes, pendingSyncHash, and PendingRelSync::rlocator.
Referenced by InitializeParallelDSM().
void smgr_redo | ( | XLogReaderState * | record | ) |
Definition at line 940 of file storage.c.
References Assert, xl_smgr_truncate::blkno, BlockNumberIsValid(), CreateFakeRelcacheEntry(), elog, XLogReaderState::EndRecPtr, xl_smgr_truncate::flags, xl_smgr_create::forkNum, FreeFakeRelcacheEntry(), FreeSpaceMapPrepareTruncateRel(), FreeSpaceMapVacuumRange(), FSM_FORKNUM, INVALID_PROC_NUMBER, InvalidBlockNumber, MAIN_FORKNUM, MAX_FORKNUM, PANIC, xl_smgr_create::rlocator, xl_smgr_truncate::rlocator, 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 632 of file storage.c.
References PendingRelDelete::atCommit, GetCurrentTransactionNestLevel(), i, PendingRelDelete::nestLevel, next, PendingRelDelete::next, palloc(), pendingDeletes, pfree(), PendingRelDelete::procNumber, repalloc(), PendingRelDelete::rlocator, smgrclose(), smgrdounlinkall(), and smgropen().
Referenced by AbortTransaction(), AtSubAbort_smgr(), and CommitTransaction().
Definition at line 700 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, INVALID_PROC_NUMBER, InvalidBlockNumber, PendingRelSync::is_truncated, RelFileLocatorBackend::locator, log_newpage_range(), MAX_FORKNUM, PendingRelDelete::next, palloc(), pendingDeletes, pendingSyncHash, pfree(), repalloc(), PendingRelDelete::rlocator, PendingRelSync::rlocator, SMgrRelationData::smgr_rlocator, smgrdosyncall(), smgrexists(), smgrnblocks(), smgropen(), and wal_skip_threshold.
Referenced by AbortTransaction(), CommitTransaction(), and PrepareTransaction().
int smgrGetPendingDeletes | ( | bool | forCommit, |
RelFileLocator ** | ptr | ||
) |
Definition at line 852 of file storage.c.
References PendingRelDelete::atCommit, GetCurrentTransactionNestLevel(), INVALID_PROC_NUMBER, PendingRelDelete::nestLevel, PendingRelDelete::next, palloc(), pendingDeletes, PendingRelDelete::procNumber, and PendingRelDelete::rlocator.
Referenced by RecordTransactionAbort(), RecordTransactionCommit(), and StartPrepare().
|
static |
Definition at line 76 of file storage.c.
Referenced by AtSubCommit_smgr(), PostPrepare_smgr(), RelationCreateStorage(), RelationDropStorage(), RelationPreserveStorage(), SerializePendingSyncs(), smgrDoPendingDeletes(), smgrDoPendingSyncs(), and smgrGetPendingDeletes().
|
static |
Definition at line 77 of file storage.c.
Referenced by AddPendingSync(), EstimatePendingSyncsSpace(), RelationPreTruncate(), RelFileLocatorSkippingWAL(), RestorePendingSyncs(), SerializePendingSyncs(), and smgrDoPendingSyncs().
int wal_skip_threshold = 2048 |
Definition at line 39 of file storage.c.
Referenced by smgrDoPendingSyncs().