122 bool register_delete)
130 switch (relpersistence)
132 case RELPERSISTENCE_TEMP:
136 case RELPERSISTENCE_UNLOGGED:
140 case RELPERSISTENCE_PERMANENT:
145 elog(
ERROR,
"invalid relpersistence: %c", relpersistence);
149 srel =
smgropen(rlocator, procNumber);
173 if (relpersistence == RELPERSISTENCE_PERMANENT && !
XLogIsNeeded())
292 bool need_fsm_vacuum =
false;
311 blocks[nforks] = nblocks;
324 need_fsm_vacuum =
true;
395 xlrec.
blkno = nblocks;
481 bool copying_initfork;
491 copying_initfork = relpersistence == RELPERSISTENCE_UNLOGGED &&
501 (relpersistence == RELPERSISTENCE_PERMANENT || copying_initfork);
507 for (blkno = 0; blkno < nblocks; blkno++)
533 errmsg(
"invalid page in block %u of relation %s",
612 if (delete->atCommit)
696 else if (maxrels <= nrels)
702 srels[nrels++] = srel;
714 for (
int i = 0;
i < nrels;
i++)
749 if (isParallelWorker)
818 else if (maxrels <= nrels)
824 srels[nrels++] = srel;
831 int n = nblocks[fork];
990 bool need_fsm_vacuum =
false;
1024 blocks[nforks] = xlrec->
blkno;
1043 need_fsm_vacuum =
true;
1071 if (need_fsm_vacuum)
1078 elog(
PANIC,
"smgr_redo: unknown op code %u", info);
#define InvalidBlockNumber
static bool BlockNumberIsValid(BlockNumber blockNumber)
bool PageIsVerifiedExtended(Page page, BlockNumber blkno, int flags)
void smgr_bulk_write(BulkWriteState *bulkstate, BlockNumber blocknum, BulkWriteBuffer buf, bool page_std)
BulkWriteBuffer smgr_bulk_get_buf(BulkWriteState *bulkstate)
BulkWriteState * smgr_bulk_start_smgr(SMgrRelation smgr, ForkNumber forknum, bool use_wal)
void smgr_bulk_finish(BulkWriteState *bulkstate)
#define Assert(condition)
#define MemSet(start, val, len)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
void hash_destroy(HTAB *hashp)
void * hash_seq_search(HASH_SEQ_STATUS *status)
long hash_get_num_entries(HTAB *hashp)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void FreeSpaceMapVacuumRange(Relation rel, BlockNumber start, BlockNumber end)
BlockNumber FreeSpaceMapPrepareTruncateRel(Relation rel, BlockNumber nblocks)
void * MemoryContextAlloc(MemoryContext context, Size size)
MemoryContext TopTransactionContext
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
MemoryContext TopMemoryContext
MemoryContext CurrentMemoryContext
#define START_CRIT_SECTION()
#define CHECK_FOR_INTERRUPTS()
#define END_CRIT_SECTION()
#define ERRCODE_DATA_CORRUPTED
#define DELAY_CHKPT_START
#define ProcNumberForTempRelations()
#define DELAY_CHKPT_COMPLETE
#define INVALID_PROC_NUMBER
static SMgrRelation RelationGetSmgr(Relation rel)
#define RelationNeedsWAL(relation)
static void RelationCloseSmgr(Relation relation)
#define AssertPendingSyncs_RelationCache()
struct RelFileLocator RelFileLocator
#define RelFileLocatorEquals(locator1, locator2)
#define relpath(rlocator, forknum)
#define relpathbackend(rlocator, backend, forknum)
Size mul_size(Size s1, Size s2)
BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum)
SMgrRelation smgropen(RelFileLocator rlocator, ProcNumber backend)
void smgrdosyncall(SMgrRelation *rels, int nrels)
void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
void smgrclose(SMgrRelation reln)
void smgrtruncate(SMgrRelation reln, ForkNumber *forknum, int nforks, BlockNumber *old_nblocks, BlockNumber *nblocks)
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
void smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
static void smgrread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, void *buffer)
void RelationPreserveStorage(RelFileLocator rlocator, bool atCommit)
void RelationPreTruncate(Relation rel)
struct PendingRelDelete PendingRelDelete
void SerializePendingSyncs(Size maxSize, char *startAddress)
void AtSubCommit_smgr(void)
Size EstimatePendingSyncsSpace(void)
static HTAB * pendingSyncHash
struct PendingRelSync PendingRelSync
static PendingRelDelete * pendingDeletes
void AtSubAbort_smgr(void)
void RelationCopyStorage(SMgrRelation src, SMgrRelation dst, ForkNumber forkNum, char relpersistence)
void smgr_redo(XLogReaderState *record)
bool RelFileLocatorSkippingWAL(RelFileLocator rlocator)
int smgrGetPendingDeletes(bool forCommit, RelFileLocator **ptr)
void PostPrepare_smgr(void)
SMgrRelation RelationCreateStorage(RelFileLocator rlocator, char relpersistence, bool register_delete)
static void AddPendingSync(const RelFileLocator *rlocator)
void RestorePendingSyncs(char *startAddress)
void log_smgrcreate(const RelFileLocator *rlocator, ForkNumber forkNum)
void RelationDropStorage(Relation rel)
void RelationTruncate(Relation rel, BlockNumber nblocks)
void smgrDoPendingSyncs(bool isCommit, bool isParallelWorker)
void smgrDoPendingDeletes(bool isCommit)
#define SMGR_TRUNCATE_ALL
#define XLOG_SMGR_TRUNCATE
#define SMGR_TRUNCATE_HEAP
#define SMGR_TRUNCATE_FSM
struct PendingRelDelete * next
RelFileLocator rd_locator
BlockNumber smgr_targblock
BlockNumber smgr_cached_nblocks[MAX_FORKNUM+1]
RelFileLocatorBackend smgr_rlocator
BlockNumber visibilitymap_prepare_truncate(Relation rel, BlockNumber nheapblocks)
int GetCurrentTransactionNestLevel(void)
bool IsInParallelMode(void)
void XLogFlush(XLogRecPtr record)
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
void XLogRegisterData(const char *data, uint32 len)
void log_newpage_range(Relation rel, ForkNumber forknum, BlockNumber startblk, BlockNumber endblk, bool page_std)
void XLogBeginInsert(void)
#define XLogRecGetInfo(decoder)
#define XLogRecGetData(decoder)
#define XLogRecHasAnyBlockRefs(decoder)
#define XLR_SPECIAL_REL_UPDATE
void FreeFakeRelcacheEntry(Relation fakerel)
void XLogTruncateRelation(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber nblocks)
Relation CreateFakeRelcacheEntry(RelFileLocator rlocator)