70#define RELMAPPER_FILENAME "pg_filenode.map"
71#define RELMAPPER_TEMP_FILENAME "pg_filenode.map.tmp"
73#define RELMAPPER_FILEMAGIC 0x592717
81#define MAX_MAPPINGS 64
146 bool send_sinval,
bool preserve_files,
147 Oid dbid,
Oid tsid,
const char *dbpath);
348 elog(
ERROR,
"cannot change relation mapping within subtransaction");
351 elog(
ERROR,
"cannot change relation mapping in parallel mode");
400 elog(
ERROR,
"attempt to apply a mapping to unmapped relation %u",
403 elog(
ERROR,
"ran out of space in relation map");
453 elog(
ERROR,
"could not find temporary mapping for relation %u",
543 if (isCommit && !isParallelWorker)
595 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
596 errmsg(
"cannot PREPARE a transaction that modified relation mapping")));
749 elog(
ERROR,
"parallel worker has existing mappings");
812 snprintf(mapfilename,
sizeof(mapfilename),
"%s/%s", dbpath,
818 errmsg(
"could not open file \"%s\": %m",
829 errmsg(
"could not read file \"%s\": %m", mapfilename)));
833 errmsg(
"could not read file \"%s\": read %d of %zu",
841 errmsg(
"could not close file \"%s\": %m",
852 (
errmsg(
"relation mapping file \"%s\" contains invalid data",
862 (
errmsg(
"relation mapping file \"%s\" contains incorrect checksum",
890 bool preserve_files,
Oid dbid,
Oid tsid,
const char *dbpath)
910 elog(
ERROR,
"attempt to write bogus relation mapping");
920 snprintf(mapfilename,
sizeof(mapfilename),
"%s/%s",
922 snprintf(maptempfilename,
sizeof(maptempfilename),
"%s/%s",
931 O_WRONLY | O_CREAT | O_TRUNC |
PG_BINARY);
935 errmsg(
"could not open file \"%s\": %m",
947 errmsg(
"could not write file \"%s\": %m",
956 errmsg(
"could not close file \"%s\": %m",
1022 rlocator.
dbOid = dbid;
1110 elog(
PANIC,
"relmap_redo: wrong size %u in relmap update record",
1112 memcpy(&newmap, xlrec->
data,
sizeof(newmap));
1140 elog(
PANIC,
"relmap_redo: unknown op code %u", info);
#define Assert(condition)
int errcode_for_file_access(void)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
int durable_rename(const char *oldfile, const char *newfile, int elevel)
int CloseTransientFile(int fd)
int OpenTransientFile(const char *fileName, int fileFlags)
bool allowSystemTableMods
void CacheInvalidateRelmap(Oid databaseId)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
bool LWLockHeldByMeInMode(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void pfree(void *pointer)
#define IsBootstrapProcessingMode()
#define START_CRIT_SECTION()
#define END_CRIT_SECTION()
#define ERRCODE_DATA_CORRUPTED
#define COMP_CRC32C(crc, data, len)
#define EQ_CRC32C(c1, c2)
static int fd(const char *x, int i)
RelFileNumber RelationMapOidToFilenumberForDatabase(char *dbpath, Oid relationId)
static RelMapFile pending_local_updates
Size EstimateRelationMapSpace(void)
void RelationMapRemoveMapping(Oid relationId)
struct RelMapping RelMapping
void SerializeRelationMap(Size maxSize, char *startAddress)
#define RELMAPPER_FILEMAGIC
void RelationMapCopy(Oid dbid, Oid tsid, char *srcdbpath, char *dstdbpath)
static void apply_map_update(RelMapFile *map, Oid relationId, RelFileNumber fileNumber, bool add_okay)
static void write_relmap_file(RelMapFile *newmap, bool write_wal, bool send_sinval, bool preserve_files, Oid dbid, Oid tsid, const char *dbpath)
Oid RelationMapFilenumberToOid(RelFileNumber filenumber, bool shared)
void RelationMapInvalidateAll(void)
void RestoreRelationMap(char *startAddress)
static RelMapFile shared_map
static RelMapFile active_local_updates
static void perform_relmap_update(bool shared, const RelMapFile *updates)
static void read_relmap_file(RelMapFile *map, char *dbpath, bool lock_held, int elevel)
void RelationMapInitialize(void)
void AtPrepare_RelationMap(void)
static RelMapFile local_map
#define RELMAPPER_TEMP_FILENAME
void relmap_redo(XLogReaderState *record)
#define RELMAPPER_FILENAME
void AtEOXact_RelationMap(bool isCommit, bool isParallelWorker)
void RelationMapInvalidate(bool shared)
static RelMapFile pending_shared_updates
void RelationMapInitializePhase2(void)
void RelationMapFinishBootstrap(void)
struct SerializedActiveRelMaps SerializedActiveRelMaps
RelFileNumber RelationMapOidToFilenumber(Oid relationId, bool shared)
void RelationMapUpdateMap(Oid relationId, RelFileNumber fileNumber, bool shared, bool immediate)
void RelationMapInitializePhase3(void)
struct RelMapFile RelMapFile
void AtCCI_RelationMap(void)
static void merge_map_updates(RelMapFile *map, const RelMapFile *updates, bool add_okay)
void CheckPointRelationMap(void)
static RelMapFile active_shared_updates
static void load_relmap_file(bool shared, bool lock_held)
#define XLOG_RELMAP_UPDATE
#define MinSizeOfRelmapUpdate
char * GetDatabasePath(Oid dbOid, Oid spcOid)
#define InvalidRelFileNumber
void RelationPreserveStorage(RelFileLocator rlocator, bool atCommit)
RelMapping mappings[MAX_MAPPINGS]
RelFileNumber mapfilenumber
RelMapFile active_local_updates
RelMapFile active_shared_updates
char data[FLEXIBLE_ARRAY_MEMBER]
static void pgstat_report_wait_start(uint32 wait_event_info)
static void pgstat_report_wait_end(void)
int GetCurrentTransactionNestLevel(void)
bool IsInParallelMode(void)
void XLogFlush(XLogRecPtr record)
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
void XLogRegisterData(const char *data, uint32 len)
void XLogBeginInsert(void)
#define XLogRecGetInfo(decoder)
#define XLogRecGetData(decoder)
#define XLogRecHasAnyBlockRefs(decoder)