1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-21 02:52:47 +03:00

Change internal RelFileNode references to RelFileNumber or RelFileLocator.

We have been using the term RelFileNode to refer to either (1) the
integer that is used to name the sequence of files for a certain relation
within the directory set aside for that tablespace/database combination;
or (2) that value plus the OIDs of the tablespace and database; or
occasionally (3) the whole series of files created for a relation
based on those values. Using the same name for more than one thing is
confusing.

Replace RelFileNode with RelFileNumber when we're talking about just the
single number, i.e. (1) from above, and with RelFileLocator when we're
talking about all the things that are needed to locate a relation's files
on disk, i.e. (2) from above. In the places where we refer to (3) as
a relfilenode, instead refer to "relation storage".

Since there is a ton of SQL code in the world that knows about
pg_class.relfilenode, don't change the name of that column, or of other
SQL-facing things that derive their name from it.

On the other hand, do adjust closely-related internal terminology. For
example, the structure member names dbNode and spcNode appear to be
derived from the fact that the structure itself was called RelFileNode,
so change those to dbOid and spcOid. Likewise, various variables with
names like rnode and relnode get renamed appropriately, according to
how they're being used in context.

Hopefully, this is clearer than before. It is also preparation for
future patches that intend to widen the relfilenumber fields from its
current width of 32 bits. Variables that store a relfilenumber are now
declared as type RelFileNumber rather than type Oid; right now, these
are the same, but that can now more easily be changed.

Dilip Kumar, per an idea from me. Reviewed also by Andres Freund.
I fixed some whitespace issues, changed a couple of words in a
comment, and made one other minor correction.

Discussion: http://postgr.es/m/CA+TgmoamOtXbVAQf9hWFzonUo6bhhjS6toZQd7HZ-pmojtAmag@mail.gmail.com
Discussion: http://postgr.es/m/CA+Tgmobp7+7kmi4gkq7Y+4AM9fTvL+O1oQ4-5gFTT+6Ng-dQ=g@mail.gmail.com
Discussion: http://postgr.es/m/CAFiTN-vTe79M8uDH1yprOU64MNFE+R3ODRuA+JWf27JbhY4hJw@mail.gmail.com
This commit is contained in:
Robert Haas
2022-07-06 11:39:09 -04:00
parent 7775c748db
commit b0a55e4329
138 changed files with 1640 additions and 1606 deletions

View File

@@ -18,7 +18,7 @@
#include "lib/stringinfo.h"
#include "storage/bufpage.h"
#include "storage/itemptr.h"
#include "storage/relfilenode.h"
#include "storage/relfilelocator.h"
#include "utils/relcache.h"

View File

@@ -110,7 +110,7 @@ typedef struct
typedef struct ginxlogSplit
{
RelFileNode node;
RelFileLocator locator;
BlockNumber rrlink; /* right link, or root's blocknumber if root
* split */
BlockNumber leftChildBlkno; /* valid on a non-leaf split */
@@ -167,7 +167,7 @@ typedef struct ginxlogDeletePage
*/
typedef struct ginxlogUpdateMeta
{
RelFileNode node;
RelFileLocator locator;
GinMetaPageData metadata;
BlockNumber prevTail;
BlockNumber newRightlink;

View File

@@ -97,7 +97,7 @@ typedef struct gistxlogPageDelete
*/
typedef struct gistxlogPageReuse
{
RelFileNode node;
RelFileLocator locator;
BlockNumber block;
FullTransactionId latestRemovedFullXid;
} gistxlogPageReuse;

View File

@@ -19,7 +19,7 @@
#include "lib/stringinfo.h"
#include "storage/buf.h"
#include "storage/bufpage.h"
#include "storage/relfilenode.h"
#include "storage/relfilelocator.h"
#include "utils/relcache.h"
@@ -370,9 +370,9 @@ typedef struct xl_heap_new_cid
CommandId combocid; /* just for debugging */
/*
* Store the relfilenode/ctid pair to facilitate lookups.
* Store the relfilelocator/ctid pair to facilitate lookups.
*/
RelFileNode target_node;
RelFileLocator target_locator;
ItemPointerData target_tid;
} xl_heap_new_cid;
@@ -415,7 +415,7 @@ extern bool heap_prepare_freeze_tuple(HeapTupleHeader tuple,
MultiXactId *relminmxid_out);
extern void heap_execute_freeze_tuple(HeapTupleHeader tuple,
xl_heap_freeze_tuple *xlrec_tp);
extern XLogRecPtr log_heap_visible(RelFileNode rnode, Buffer heap_buffer,
extern XLogRecPtr log_heap_visible(RelFileLocator rlocator, Buffer heap_buffer,
Buffer vm_buffer, TransactionId cutoff_xid, uint8 flags);
#endif /* HEAPAM_XLOG_H */

View File

@@ -180,12 +180,12 @@ typedef struct xl_btree_dedup
* This is what we need to know about page reuse within btree. This record
* only exists to generate a conflict point for Hot Standby.
*
* Note that we must include a RelFileNode in the record because we don't
* Note that we must include a RelFileLocator in the record because we don't
* actually register the buffer with the record.
*/
typedef struct xl_btree_reuse_page
{
RelFileNode node;
RelFileLocator locator;
BlockNumber block;
FullTransactionId latestRemovedFullXid;
} xl_btree_reuse_page;

View File

@@ -15,7 +15,7 @@
#include "access/htup.h"
#include "storage/itemptr.h"
#include "storage/relfilenode.h"
#include "storage/relfilelocator.h"
#include "utils/relcache.h"
/* struct definition is private to rewriteheap.c */
@@ -34,8 +34,8 @@ extern bool rewrite_heap_dead_tuple(RewriteState state, HeapTuple oldTuple);
*/
typedef struct LogicalRewriteMappingData
{
RelFileNode old_node;
RelFileNode new_node;
RelFileLocator old_locator;
RelFileLocator new_locator;
ItemPointerData old_tid;
ItemPointerData new_tid;
} LogicalRewriteMappingData;

View File

@@ -560,32 +560,32 @@ typedef struct TableAmRoutine
*/
/*
* This callback needs to create a new relation filenode for `rel`, with
* This callback needs to create new relation storage for `rel`, with
* appropriate durability behaviour for `persistence`.
*
* Note that only the subset of the relcache filled by
* RelationBuildLocalRelation() can be relied upon and that the relation's
* catalog entries will either not yet exist (new relation), or will still
* reference the old relfilenode.
* reference the old relfilelocator.
*
* As output *freezeXid, *minmulti must be set to the values appropriate
* for pg_class.{relfrozenxid, relminmxid}. For AMs that don't need those
* fields to be filled they can be set to InvalidTransactionId and
* InvalidMultiXactId, respectively.
*
* See also table_relation_set_new_filenode().
* See also table_relation_set_new_filelocator().
*/
void (*relation_set_new_filenode) (Relation rel,
const RelFileNode *newrnode,
char persistence,
TransactionId *freezeXid,
MultiXactId *minmulti);
void (*relation_set_new_filelocator) (Relation rel,
const RelFileLocator *newrlocator,
char persistence,
TransactionId *freezeXid,
MultiXactId *minmulti);
/*
* This callback needs to remove all contents from `rel`'s current
* relfilenode. No provisions for transactional behaviour need to be made.
* Often this can be implemented by truncating the underlying storage to
* its minimal size.
* relfilelocator. No provisions for transactional behaviour need to be
* made. Often this can be implemented by truncating the underlying
* storage to its minimal size.
*
* See also table_relation_nontransactional_truncate().
*/
@@ -598,7 +598,7 @@ typedef struct TableAmRoutine
* storage, unless it contains references to the tablespace internally.
*/
void (*relation_copy_data) (Relation rel,
const RelFileNode *newrnode);
const RelFileLocator *newrlocator);
/* See table_relation_copy_for_cluster() */
void (*relation_copy_for_cluster) (Relation NewTable,
@@ -1348,7 +1348,7 @@ table_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
* RelationGetBufferForTuple. See that method for more information.
*
* TABLE_INSERT_FROZEN should only be specified for inserts into
* relfilenodes created during the current subtransaction and when
* relation storage created during the current subtransaction and when
* there are no prior snapshots or pre-existing portals open.
* This causes rows to be frozen, which is an MVCC violation and
* requires explicit options chosen by user.
@@ -1577,33 +1577,34 @@ table_finish_bulk_insert(Relation rel, int options)
*/
/*
* Create storage for `rel` in `newrnode`, with persistence set to
* Create storage for `rel` in `newrlocator`, with persistence set to
* `persistence`.
*
* This is used both during relation creation and various DDL operations to
* create a new relfilenode that can be filled from scratch. When creating
* new storage for an existing relfilenode, this should be called before the
* create new rel storage that can be filled from scratch. When creating
* new storage for an existing relfilelocator, this should be called before the
* relcache entry has been updated.
*
* *freezeXid, *minmulti are set to the xid / multixact horizon for the table
* that pg_class.{relfrozenxid, relminmxid} have to be set to.
*/
static inline void
table_relation_set_new_filenode(Relation rel,
const RelFileNode *newrnode,
char persistence,
TransactionId *freezeXid,
MultiXactId *minmulti)
table_relation_set_new_filelocator(Relation rel,
const RelFileLocator *newrlocator,
char persistence,
TransactionId *freezeXid,
MultiXactId *minmulti)
{
rel->rd_tableam->relation_set_new_filenode(rel, newrnode, persistence,
freezeXid, minmulti);
rel->rd_tableam->relation_set_new_filelocator(rel, newrlocator,
persistence, freezeXid,
minmulti);
}
/*
* Remove all table contents from `rel`, in a non-transactional manner.
* Non-transactional meaning that there's no need to support rollbacks. This
* commonly only is used to perform truncations for relfilenodes created in the
* current transaction.
* commonly only is used to perform truncations for relation storage created in
* the current transaction.
*/
static inline void
table_relation_nontransactional_truncate(Relation rel)
@@ -1612,15 +1613,15 @@ table_relation_nontransactional_truncate(Relation rel)
}
/*
* Copy data from `rel` into the new relfilenode `newrnode`. The new
* relfilenode may not have storage associated before this function is
* Copy data from `rel` into the new relfilelocator `newrlocator`. The new
* relfilelocator may not have storage associated before this function is
* called. This is only supposed to be used for low level operations like
* changing a relation's tablespace.
*/
static inline void
table_relation_copy_data(Relation rel, const RelFileNode *newrnode)
table_relation_copy_data(Relation rel, const RelFileLocator *newrlocator)
{
rel->rd_tableam->relation_copy_data(rel, newrnode);
rel->rd_tableam->relation_copy_data(rel, newrlocator);
}
/*

View File

@@ -19,7 +19,7 @@
#include "datatype/timestamp.h"
#include "lib/stringinfo.h"
#include "nodes/pg_list.h"
#include "storage/relfilenode.h"
#include "storage/relfilelocator.h"
#include "storage/sinval.h"
/*
@@ -174,7 +174,7 @@ typedef struct SavedTransactionCharacteristics
*/
#define XACT_XINFO_HAS_DBINFO (1U << 0)
#define XACT_XINFO_HAS_SUBXACTS (1U << 1)
#define XACT_XINFO_HAS_RELFILENODES (1U << 2)
#define XACT_XINFO_HAS_RELFILELOCATORS (1U << 2)
#define XACT_XINFO_HAS_INVALS (1U << 3)
#define XACT_XINFO_HAS_TWOPHASE (1U << 4)
#define XACT_XINFO_HAS_ORIGIN (1U << 5)
@@ -252,12 +252,12 @@ typedef struct xl_xact_subxacts
} xl_xact_subxacts;
#define MinSizeOfXactSubxacts offsetof(xl_xact_subxacts, subxacts)
typedef struct xl_xact_relfilenodes
typedef struct xl_xact_relfilelocators
{
int nrels; /* number of relations */
RelFileNode xnodes[FLEXIBLE_ARRAY_MEMBER];
} xl_xact_relfilenodes;
#define MinSizeOfXactRelfilenodes offsetof(xl_xact_relfilenodes, xnodes)
RelFileLocator xlocators[FLEXIBLE_ARRAY_MEMBER];
} xl_xact_relfilelocators;
#define MinSizeOfXactRelfileLocators offsetof(xl_xact_relfilelocators, xlocators)
/*
* A transactionally dropped statistics entry.
@@ -305,7 +305,7 @@ typedef struct xl_xact_commit
/* xl_xact_xinfo follows if XLOG_XACT_HAS_INFO */
/* xl_xact_dbinfo follows if XINFO_HAS_DBINFO */
/* xl_xact_subxacts follows if XINFO_HAS_SUBXACT */
/* xl_xact_relfilenodes follows if XINFO_HAS_RELFILENODES */
/* xl_xact_relfilelocators follows if XINFO_HAS_RELFILELOCATORS */
/* xl_xact_stats_items follows if XINFO_HAS_DROPPED_STATS */
/* xl_xact_invals follows if XINFO_HAS_INVALS */
/* xl_xact_twophase follows if XINFO_HAS_TWOPHASE */
@@ -321,7 +321,7 @@ typedef struct xl_xact_abort
/* xl_xact_xinfo follows if XLOG_XACT_HAS_INFO */
/* xl_xact_dbinfo follows if XINFO_HAS_DBINFO */
/* xl_xact_subxacts follows if XINFO_HAS_SUBXACT */
/* xl_xact_relfilenodes follows if XINFO_HAS_RELFILENODES */
/* xl_xact_relfilelocators follows if XINFO_HAS_RELFILELOCATORS */
/* xl_xact_stats_items follows if XINFO_HAS_DROPPED_STATS */
/* No invalidation messages needed. */
/* xl_xact_twophase follows if XINFO_HAS_TWOPHASE */
@@ -367,7 +367,7 @@ typedef struct xl_xact_parsed_commit
TransactionId *subxacts;
int nrels;
RelFileNode *xnodes;
RelFileLocator *xlocators;
int nstats;
xl_xact_stats_item *stats;
@@ -378,7 +378,7 @@ typedef struct xl_xact_parsed_commit
TransactionId twophase_xid; /* only for 2PC */
char twophase_gid[GIDSIZE]; /* only for 2PC */
int nabortrels; /* only for 2PC */
RelFileNode *abortnodes; /* only for 2PC */
RelFileLocator *abortlocators; /* only for 2PC */
int nabortstats; /* only for 2PC */
xl_xact_stats_item *abortstats; /* only for 2PC */
@@ -400,7 +400,7 @@ typedef struct xl_xact_parsed_abort
TransactionId *subxacts;
int nrels;
RelFileNode *xnodes;
RelFileLocator *xlocators;
int nstats;
xl_xact_stats_item *stats;
@@ -483,7 +483,7 @@ extern int xactGetCommittedChildren(TransactionId **ptr);
extern XLogRecPtr XactLogCommitRecord(TimestampTz commit_time,
int nsubxacts, TransactionId *subxacts,
int nrels, RelFileNode *rels,
int nrels, RelFileLocator *rels,
int nstats,
xl_xact_stats_item *stats,
int nmsgs, SharedInvalidationMessage *msgs,
@@ -494,7 +494,7 @@ extern XLogRecPtr XactLogCommitRecord(TimestampTz commit_time,
extern XLogRecPtr XactLogAbortRecord(TimestampTz abort_time,
int nsubxacts, TransactionId *subxacts,
int nrels, RelFileNode *rels,
int nrels, RelFileLocator *rels,
int nstats,
xl_xact_stats_item *stats,
int xactflags, TransactionId twophase_xid,

View File

@@ -25,7 +25,7 @@
#include "lib/stringinfo.h"
#include "pgtime.h"
#include "storage/block.h"
#include "storage/relfilenode.h"
#include "storage/relfilelocator.h"
/*

View File

@@ -15,7 +15,7 @@
#include "access/xlogdefs.h"
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/relfilenode.h"
#include "storage/relfilelocator.h"
#include "utils/relcache.h"
/*
@@ -45,16 +45,16 @@ extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info);
extern void XLogEnsureRecordSpace(int max_block_id, int ndatas);
extern void XLogRegisterData(char *data, int len);
extern void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags);
extern void XLogRegisterBlock(uint8 block_id, RelFileNode *rnode,
extern void XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator,
ForkNumber forknum, BlockNumber blknum, char *page,
uint8 flags);
extern void XLogRegisterBufData(uint8 block_id, char *data, int len);
extern void XLogResetInsertion(void);
extern bool XLogCheckBufferNeedsBackup(Buffer buffer);
extern XLogRecPtr log_newpage(RelFileNode *rnode, ForkNumber forkNum,
extern XLogRecPtr log_newpage(RelFileLocator *rlocator, ForkNumber forkNum,
BlockNumber blk, char *page, bool page_std);
extern void log_newpages(RelFileNode *rnode, ForkNumber forkNum, int num_pages,
extern void log_newpages(RelFileLocator *rlocator, ForkNumber forkNum, int num_pages,
BlockNumber *blknos, char **pages, bool page_std);
extern XLogRecPtr log_newpage_buffer(Buffer buffer, bool page_std);
extern void log_newpage_range(Relation rel, ForkNumber forkNum,

View File

@@ -122,7 +122,7 @@ typedef struct
bool in_use;
/* Identify the block this refers to */
RelFileNode rnode;
RelFileLocator rlocator;
ForkNumber forknum;
BlockNumber blkno;
@@ -430,10 +430,10 @@ extern FullTransactionId XLogRecGetFullXid(XLogReaderState *record);
extern bool RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page);
extern char *XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len);
extern void XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id,
RelFileNode *rnode, ForkNumber *forknum,
RelFileLocator *rlocator, ForkNumber *forknum,
BlockNumber *blknum);
extern bool XLogRecGetBlockTagExtended(XLogReaderState *record, uint8 block_id,
RelFileNode *rnode, ForkNumber *forknum,
RelFileLocator *rlocator, ForkNumber *forknum,
BlockNumber *blknum,
Buffer *prefetch_buffer);

View File

@@ -15,7 +15,7 @@
#include "access/xlogdefs.h"
#include "port/pg_crc32c.h"
#include "storage/block.h"
#include "storage/relfilenode.h"
#include "storage/relfilelocator.h"
/*
* The overall layout of an XLOG record is:
@@ -97,7 +97,7 @@ typedef struct XLogRecordBlockHeader
* image) */
/* If BKPBLOCK_HAS_IMAGE, an XLogRecordBlockImageHeader struct follows */
/* If BKPBLOCK_SAME_REL is not set, a RelFileNode follows */
/* If BKPBLOCK_SAME_REL is not set, a RelFileLocator follows */
/* BlockNumber follows */
} XLogRecordBlockHeader;
@@ -175,7 +175,7 @@ typedef struct XLogRecordBlockCompressHeader
(SizeOfXLogRecordBlockHeader + \
SizeOfXLogRecordBlockImageHeader + \
SizeOfXLogRecordBlockCompressHeader + \
sizeof(RelFileNode) + \
sizeof(RelFileLocator) + \
sizeof(BlockNumber))
/*
@@ -187,7 +187,8 @@ typedef struct XLogRecordBlockCompressHeader
#define BKPBLOCK_HAS_IMAGE 0x10 /* block data is an XLogRecordBlockImage */
#define BKPBLOCK_HAS_DATA 0x20
#define BKPBLOCK_WILL_INIT 0x40 /* redo will re-init the page */
#define BKPBLOCK_SAME_REL 0x80 /* RelFileNode omitted, same as previous */
#define BKPBLOCK_SAME_REL 0x80 /* RelFileLocator omitted, same as
* previous */
/*
* XLogRecordDataHeaderShort/Long are used for the "main data" portion of

View File

@@ -60,9 +60,9 @@ extern PGDLLIMPORT HotStandbyState standbyState;
extern bool XLogHaveInvalidPages(void);
extern void XLogCheckInvalidPages(void);
extern void XLogDropRelation(RelFileNode rnode, ForkNumber forknum);
extern void XLogDropRelation(RelFileLocator rlocator, ForkNumber forknum);
extern void XLogDropDatabase(Oid dbid);
extern void XLogTruncateRelation(RelFileNode rnode, ForkNumber forkNum,
extern void XLogTruncateRelation(RelFileLocator rlocator, ForkNumber forkNum,
BlockNumber nblocks);
/* Result codes for XLogReadBufferForRedo[Extended] */
@@ -89,11 +89,11 @@ extern XLogRedoAction XLogReadBufferForRedoExtended(XLogReaderState *record,
ReadBufferMode mode, bool get_cleanup_lock,
Buffer *buf);
extern Buffer XLogReadBufferExtended(RelFileNode rnode, ForkNumber forknum,
extern Buffer XLogReadBufferExtended(RelFileLocator rlocator, ForkNumber forknum,
BlockNumber blkno, ReadBufferMode mode,
Buffer recent_buffer);
extern Relation CreateFakeRelcacheEntry(RelFileNode rnode);
extern Relation CreateFakeRelcacheEntry(RelFileLocator rlocator);
extern void FreeFakeRelcacheEntry(Relation fakerel);
extern int read_local_xlog_page(XLogReaderState *state,