PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include "access/xact.h"
#include "access/xlog.h"
#include "access/xloginsert.h"
#include "catalog/catalog.h"
#include "catalog/pg_tablespace.h"
#include "catalog/storage.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/lwlock.h"
#include "utils/inval.h"
#include "utils/relmapper.h"
Go to the source code of this file.
Data Structures | |
struct | RelMapping |
struct | RelMapFile |
struct | SerializedActiveRelMaps |
Macros | |
#define | RELMAPPER_FILENAME "pg_filenode.map" |
#define | RELMAPPER_FILEMAGIC 0x592717 /* version ID value */ |
#define | MAX_MAPPINGS 62 /* 62 * 8 + 16 = 512 */ |
Typedefs | |
typedef struct RelMapping | RelMapping |
typedef struct RelMapFile | RelMapFile |
typedef struct SerializedActiveRelMaps | SerializedActiveRelMaps |
Functions | |
static void | apply_map_update (RelMapFile *map, Oid relationId, Oid fileNode, bool add_okay) |
static void | merge_map_updates (RelMapFile *map, const RelMapFile *updates, bool add_okay) |
static void | load_relmap_file (bool shared) |
static void | write_relmap_file (bool shared, RelMapFile *newmap, bool write_wal, bool send_sinval, bool preserve_files, Oid dbid, Oid tsid, const char *dbpath) |
static void | perform_relmap_update (bool shared, const RelMapFile *updates) |
Oid | RelationMapOidToFilenode (Oid relationId, bool shared) |
Oid | RelationMapFilenodeToOid (Oid filenode, bool shared) |
void | RelationMapUpdateMap (Oid relationId, Oid fileNode, bool shared, bool immediate) |
void | RelationMapRemoveMapping (Oid relationId) |
void | RelationMapInvalidate (bool shared) |
void | RelationMapInvalidateAll (void) |
void | AtCCI_RelationMap (void) |
void | AtEOXact_RelationMap (bool isCommit, bool isParallelWorker) |
void | AtPrepare_RelationMap (void) |
void | CheckPointRelationMap (void) |
void | RelationMapFinishBootstrap (void) |
void | RelationMapInitialize (void) |
void | RelationMapInitializePhase2 (void) |
void | RelationMapInitializePhase3 (void) |
Size | EstimateRelationMapSpace (void) |
void | SerializeRelationMap (Size maxSize, char *startAddress) |
void | RestoreRelationMap (char *startAddress) |
void | relmap_redo (XLogReaderState *record) |
Variables | |
static RelMapFile | shared_map |
static RelMapFile | local_map |
static RelMapFile | active_shared_updates |
static RelMapFile | active_local_updates |
static RelMapFile | pending_shared_updates |
static RelMapFile | pending_local_updates |
#define MAX_MAPPINGS 62 /* 62 * 8 + 16 = 512 */ |
Definition at line 77 of file relmapper.c.
Referenced by apply_map_update(), load_relmap_file(), and write_relmap_file().
#define RELMAPPER_FILEMAGIC 0x592717 /* version ID value */ |
Definition at line 75 of file relmapper.c.
Referenced by load_relmap_file(), RelationMapInvalidate(), RelationMapInvalidateAll(), and write_relmap_file().
#define RELMAPPER_FILENAME "pg_filenode.map" |
Definition at line 73 of file relmapper.c.
Referenced by load_relmap_file(), and write_relmap_file().
typedef struct RelMapFile RelMapFile |
typedef struct RelMapping RelMapping |
typedef struct SerializedActiveRelMaps SerializedActiveRelMaps |
|
static |
Definition at line 319 of file relmapper.c.
References elog, ERROR, i, RelMapping::mapfilenode, RelMapping::mapoid, RelMapFile::mappings, MAX_MAPPINGS, and RelMapFile::num_mappings.
Referenced by merge_map_updates(), and RelationMapUpdateMap().
void AtCCI_RelationMap | ( | void | ) |
Definition at line 439 of file relmapper.c.
References merge_map_updates(), and RelMapFile::num_mappings.
Referenced by AtCCI_LocalCache().
Definition at line 476 of file relmapper.c.
References Assert, RelMapFile::num_mappings, and perform_relmap_update().
Referenced by AbortTransaction(), and CommitTransaction().
void AtPrepare_RelationMap | ( | void | ) |
Definition at line 523 of file relmapper.c.
References ereport, errcode(), errmsg(), ERROR, and RelMapFile::num_mappings.
Referenced by PrepareTransaction().
void CheckPointRelationMap | ( | void | ) |
Definition at line 546 of file relmapper.c.
References LW_SHARED, LWLockAcquire(), and LWLockRelease().
Referenced by CheckPointGuts().
Size EstimateRelationMapSpace | ( | void | ) |
Definition at line 646 of file relmapper.c.
Referenced by InitializeParallelDSM(), and SerializeRelationMap().
|
static |
Definition at line 698 of file relmapper.c.
References CloseTransientFile(), COMP_CRC32C, DatabasePath, EQ_CRC32C, ereport, errcode(), ERRCODE_DATA_CORRUPTED, errcode_for_file_access(), errmsg(), FATAL, fd(), FIN_CRC32C, INIT_CRC32C, local_map, RelMapFile::magic, MAX_MAPPINGS, MAXPGPATH, RelMapFile::num_mappings, offsetof, OpenTransientFile(), PG_BINARY, pgstat_report_wait_end(), pgstat_report_wait_start(), read, RELMAPPER_FILEMAGIC, RELMAPPER_FILENAME, shared_map, snprintf, and WAIT_EVENT_RELATION_MAP_READ.
Referenced by perform_relmap_update(), RelationMapInitializePhase2(), RelationMapInitializePhase3(), RelationMapInvalidate(), and RelationMapInvalidateAll().
|
static |
Definition at line 351 of file relmapper.c.
References apply_map_update(), i, RelMapping::mapfilenode, RelMapping::mapoid, RelMapFile::mappings, and RelMapFile::num_mappings.
Referenced by AtCCI_RelationMap(), and perform_relmap_update().
|
static |
Definition at line 952 of file relmapper.c.
References allowSystemTableMods, DatabasePath, InvalidOid, load_relmap_file(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), merge_map_updates(), MyDatabaseId, MyDatabaseTableSpace, and write_relmap_file().
Referenced by AtEOXact_RelationMap().
Definition at line 212 of file relmapper.c.
References active_local_updates, active_shared_updates, i, InvalidOid, local_map, RelMapping::mapfilenode, RelMapping::mapoid, RelMapFile::mappings, RelMapFile::num_mappings, and shared_map.
Referenced by RelidByRelfilenode().
void RelationMapFinishBootstrap | ( | void | ) |
Definition at line 560 of file relmapper.c.
References Assert, DatabasePath, InvalidOid, IsBootstrapProcessingMode, MyDatabaseId, MyDatabaseTableSpace, RelMapFile::num_mappings, and write_relmap_file().
Referenced by BootstrapModeMain().
void RelationMapInitialize | ( | void | ) |
Definition at line 584 of file relmapper.c.
References RelMapFile::magic, and RelMapFile::num_mappings.
Referenced by RelationCacheInitialize().
void RelationMapInitializePhase2 | ( | void | ) |
Definition at line 604 of file relmapper.c.
References IsBootstrapProcessingMode, and load_relmap_file().
Referenced by RelationCacheInitializePhase2().
void RelationMapInitializePhase3 | ( | void | ) |
Definition at line 625 of file relmapper.c.
References IsBootstrapProcessingMode, and load_relmap_file().
Referenced by RelationCacheInitializePhase3().
void RelationMapInvalidate | ( | bool | shared | ) |
Definition at line 403 of file relmapper.c.
References load_relmap_file(), RelMapFile::magic, and RELMAPPER_FILEMAGIC.
Referenced by LocalExecuteInvalidationMessage().
void RelationMapInvalidateAll | ( | void | ) |
Definition at line 425 of file relmapper.c.
References load_relmap_file(), RelMapFile::magic, and RELMAPPER_FILEMAGIC.
Referenced by RelationCacheInvalidate().
Definition at line 159 of file relmapper.c.
References active_local_updates, active_shared_updates, i, InvalidOid, local_map, RelMapping::mapfilenode, RelMapping::mapoid, RelMapFile::mappings, RelMapFile::num_mappings, and shared_map.
Referenced by pg_relation_filenode(), pg_relation_filepath(), RelationInitPhysicalAddr(), and swap_relation_files().
void RelationMapRemoveMapping | ( | Oid | relationId | ) |
Definition at line 373 of file relmapper.c.
References active_local_updates, elog, ERROR, i, RelMapping::mapoid, RelMapFile::mappings, and RelMapFile::num_mappings.
Referenced by finish_heap_swap().
Definition at line 261 of file relmapper.c.
References active_local_updates, active_shared_updates, apply_map_update(), elog, ERROR, GetCurrentTransactionNestLevel(), IsBootstrapProcessingMode, IsInParallelMode(), local_map, pending_local_updates, pending_shared_updates, and shared_map.
Referenced by formrdesc(), RelationBuildLocalRelation(), RelationSetNewRelfilenode(), and swap_relation_files().
void relmap_redo | ( | XLogReaderState * | record | ) |
Definition at line 1000 of file relmapper.c.
References Assert, xl_relmap_update::data, xl_relmap_update::dbid, elog, GetDatabasePath(), InvalidOid, xl_relmap_update::nbytes, PANIC, pfree(), xl_relmap_update::tsid, write_relmap_file(), XLOG_RELMAP_UPDATE, XLogRecGetData, XLogRecGetInfo, XLogRecHasAnyBlockRefs, and XLR_INFO_MASK.
void RestoreRelationMap | ( | char * | startAddress | ) |
Definition at line 674 of file relmapper.c.
References SerializedActiveRelMaps::active_local_updates, SerializedActiveRelMaps::active_shared_updates, elog, ERROR, and RelMapFile::num_mappings.
Referenced by ParallelWorkerMain().
void SerializeRelationMap | ( | Size | maxSize, |
char * | startAddress | ||
) |
Definition at line 657 of file relmapper.c.
References SerializedActiveRelMaps::active_local_updates, active_local_updates, SerializedActiveRelMaps::active_shared_updates, active_shared_updates, Assert, and EstimateRelationMapSpace().
Referenced by InitializeParallelDSM().
|
static |
Definition at line 796 of file relmapper.c.
References Assert, CacheInvalidateRelmap(), CloseTransientFile(), COMP_CRC32C, RelMapFile::crc, data_sync_elevel(), xl_relmap_update::dbid, RelFileNode::dbNode, elog, END_CRIT_SECTION, ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), FIN_CRC32C, i, INIT_CRC32C, local_map, RelMapFile::magic, MAX_MAPPINGS, MAXPGPATH, MinSizeOfRelmapUpdate, xl_relmap_update::nbytes, RelMapFile::num_mappings, offsetof, OpenTransientFile(), PG_BINARY, pg_fsync(), pgstat_report_wait_end(), pgstat_report_wait_start(), RelationPreserveStorage(), RELMAPPER_FILEMAGIC, RELMAPPER_FILENAME, RelFileNode::relNode, shared_map, snprintf, RelFileNode::spcNode, START_CRIT_SECTION, xl_relmap_update::tsid, WAIT_EVENT_RELATION_MAP_SYNC, WAIT_EVENT_RELATION_MAP_WRITE, write, XLOG_RELMAP_UPDATE, XLogBeginInsert(), XLogFlush(), XLogInsert(), and XLogRegisterData().
Referenced by perform_relmap_update(), RelationMapFinishBootstrap(), and relmap_redo().
|
static |
Definition at line 129 of file relmapper.c.
Referenced by RelationMapFilenodeToOid(), RelationMapOidToFilenode(), RelationMapRemoveMapping(), RelationMapUpdateMap(), and SerializeRelationMap().
|
static |
Definition at line 128 of file relmapper.c.
Referenced by RelationMapFilenodeToOid(), RelationMapOidToFilenode(), RelationMapUpdateMap(), and SerializeRelationMap().
|
static |
Definition at line 110 of file relmapper.c.
Referenced by load_relmap_file(), RelationMapFilenodeToOid(), RelationMapOidToFilenode(), RelationMapUpdateMap(), and write_relmap_file().
|
static |
Definition at line 131 of file relmapper.c.
Referenced by RelationMapUpdateMap().
|
static |
Definition at line 130 of file relmapper.c.
Referenced by RelationMapUpdateMap().
|
static |
Definition at line 109 of file relmapper.c.
Referenced by load_relmap_file(), RelationMapFilenodeToOid(), RelationMapOidToFilenode(), RelationMapUpdateMap(), and write_relmap_file().