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;
309 blocks[nforks] = nblocks;
321 need_fsm_vacuum =
true;
372 xlrec.
blkno = nblocks;
456 bool copying_initfork;
466 copying_initfork = relpersistence == RELPERSISTENCE_UNLOGGED &&
476 (relpersistence == RELPERSISTENCE_PERMANENT || copying_initfork);
482 for (blkno = 0; blkno < nblocks; blkno++)
508 errmsg(
"invalid page in block %u of relation %s",
587 if (delete->atCommit)
671 else if (maxrels <= nrels)
677 srels[nrels++] = srel;
689 for (
int i = 0;
i < nrels;
i++)
724 if (isParallelWorker)
793 else if (maxrels <= nrels)
799 srels[nrels++] = srel;
806 int n = nblocks[fork];
964 bool need_fsm_vacuum =
false;
997 blocks[nforks] = xlrec->
blkno;
1015 need_fsm_vacuum =
true;
1038 if (need_fsm_vacuum)
1045 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_destroy(HTAB *hashp)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
long hash_get_num_entries(HTAB *hashp)
void * hash_seq_search(HASH_SEQ_STATUS *status)
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)
MemoryContext TopTransactionContext
void pfree(void *pointer)
MemoryContext TopMemoryContext
MemoryContext CurrentMemoryContext
void * repalloc(void *pointer, Size size)
void * MemoryContextAlloc(MemoryContext context, Size size)
#define CHECK_FOR_INTERRUPTS()
#define ERRCODE_DATA_CORRUPTED
#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 *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)