mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +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:
@ -8189,7 +8189,7 @@ log_heap_freeze(Relation reln, Buffer buffer, TransactionId cutoff_xid,
|
||||
* heap_buffer, if necessary.
|
||||
*/
|
||||
XLogRecPtr
|
||||
log_heap_visible(RelFileNode rnode, Buffer heap_buffer, Buffer vm_buffer,
|
||||
log_heap_visible(RelFileLocator rlocator, Buffer heap_buffer, Buffer vm_buffer,
|
||||
TransactionId cutoff_xid, uint8 vmflags)
|
||||
{
|
||||
xl_heap_visible xlrec;
|
||||
@ -8454,7 +8454,7 @@ log_heap_new_cid(Relation relation, HeapTuple tup)
|
||||
Assert(tup->t_tableOid != InvalidOid);
|
||||
|
||||
xlrec.top_xid = GetTopTransactionId();
|
||||
xlrec.target_node = relation->rd_node;
|
||||
xlrec.target_locator = relation->rd_locator;
|
||||
xlrec.target_tid = tup->t_self;
|
||||
|
||||
/*
|
||||
@ -8623,18 +8623,18 @@ heap_xlog_prune(XLogReaderState *record)
|
||||
XLogRecPtr lsn = record->EndRecPtr;
|
||||
xl_heap_prune *xlrec = (xl_heap_prune *) XLogRecGetData(record);
|
||||
Buffer buffer;
|
||||
RelFileNode rnode;
|
||||
RelFileLocator rlocator;
|
||||
BlockNumber blkno;
|
||||
XLogRedoAction action;
|
||||
|
||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno);
|
||||
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &blkno);
|
||||
|
||||
/*
|
||||
* We're about to remove tuples. In Hot Standby mode, ensure that there's
|
||||
* no queries running for which the removed tuples are still visible.
|
||||
*/
|
||||
if (InHotStandby)
|
||||
ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid, rnode);
|
||||
ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid, rlocator);
|
||||
|
||||
/*
|
||||
* If we have a full-page image, restore it (using a cleanup lock) and
|
||||
@ -8694,7 +8694,7 @@ heap_xlog_prune(XLogReaderState *record)
|
||||
* Do this regardless of a full-page image being applied, since the
|
||||
* FSM data is not in the page anyway.
|
||||
*/
|
||||
XLogRecordPageWithFreeSpace(rnode, blkno, freespace);
|
||||
XLogRecordPageWithFreeSpace(rlocator, blkno, freespace);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8751,9 +8751,9 @@ heap_xlog_vacuum(XLogReaderState *record)
|
||||
if (BufferIsValid(buffer))
|
||||
{
|
||||
Size freespace = PageGetHeapFreeSpace(BufferGetPage(buffer));
|
||||
RelFileNode rnode;
|
||||
RelFileLocator rlocator;
|
||||
|
||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno);
|
||||
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &blkno);
|
||||
|
||||
UnlockReleaseBuffer(buffer);
|
||||
|
||||
@ -8766,7 +8766,7 @@ heap_xlog_vacuum(XLogReaderState *record)
|
||||
* Do this regardless of a full-page image being applied, since the
|
||||
* FSM data is not in the page anyway.
|
||||
*/
|
||||
XLogRecordPageWithFreeSpace(rnode, blkno, freespace);
|
||||
XLogRecordPageWithFreeSpace(rlocator, blkno, freespace);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8786,11 +8786,11 @@ heap_xlog_visible(XLogReaderState *record)
|
||||
Buffer vmbuffer = InvalidBuffer;
|
||||
Buffer buffer;
|
||||
Page page;
|
||||
RelFileNode rnode;
|
||||
RelFileLocator rlocator;
|
||||
BlockNumber blkno;
|
||||
XLogRedoAction action;
|
||||
|
||||
XLogRecGetBlockTag(record, 1, &rnode, NULL, &blkno);
|
||||
XLogRecGetBlockTag(record, 1, &rlocator, NULL, &blkno);
|
||||
|
||||
/*
|
||||
* If there are any Hot Standby transactions running that have an xmin
|
||||
@ -8802,7 +8802,7 @@ heap_xlog_visible(XLogReaderState *record)
|
||||
* rather than killing the transaction outright.
|
||||
*/
|
||||
if (InHotStandby)
|
||||
ResolveRecoveryConflictWithSnapshot(xlrec->cutoff_xid, rnode);
|
||||
ResolveRecoveryConflictWithSnapshot(xlrec->cutoff_xid, rlocator);
|
||||
|
||||
/*
|
||||
* Read the heap page, if it still exists. If the heap file has dropped or
|
||||
@ -8865,7 +8865,7 @@ heap_xlog_visible(XLogReaderState *record)
|
||||
* FSM data is not in the page anyway.
|
||||
*/
|
||||
if (xlrec->flags & VISIBILITYMAP_VALID_BITS)
|
||||
XLogRecordPageWithFreeSpace(rnode, blkno, space);
|
||||
XLogRecordPageWithFreeSpace(rlocator, blkno, space);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -8890,7 +8890,7 @@ heap_xlog_visible(XLogReaderState *record)
|
||||
*/
|
||||
LockBuffer(vmbuffer, BUFFER_LOCK_UNLOCK);
|
||||
|
||||
reln = CreateFakeRelcacheEntry(rnode);
|
||||
reln = CreateFakeRelcacheEntry(rlocator);
|
||||
visibilitymap_pin(reln, blkno, &vmbuffer);
|
||||
|
||||
/*
|
||||
@ -8933,13 +8933,13 @@ heap_xlog_freeze_page(XLogReaderState *record)
|
||||
*/
|
||||
if (InHotStandby)
|
||||
{
|
||||
RelFileNode rnode;
|
||||
RelFileLocator rlocator;
|
||||
TransactionId latestRemovedXid = cutoff_xid;
|
||||
|
||||
TransactionIdRetreat(latestRemovedXid);
|
||||
|
||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, NULL);
|
||||
ResolveRecoveryConflictWithSnapshot(latestRemovedXid, rnode);
|
||||
XLogRecGetBlockTag(record, 0, &rlocator, NULL, NULL);
|
||||
ResolveRecoveryConflictWithSnapshot(latestRemovedXid, rlocator);
|
||||
}
|
||||
|
||||
if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
|
||||
@ -9007,10 +9007,10 @@ heap_xlog_delete(XLogReaderState *record)
|
||||
ItemId lp = NULL;
|
||||
HeapTupleHeader htup;
|
||||
BlockNumber blkno;
|
||||
RelFileNode target_node;
|
||||
RelFileLocator target_locator;
|
||||
ItemPointerData target_tid;
|
||||
|
||||
XLogRecGetBlockTag(record, 0, &target_node, NULL, &blkno);
|
||||
XLogRecGetBlockTag(record, 0, &target_locator, NULL, &blkno);
|
||||
ItemPointerSetBlockNumber(&target_tid, blkno);
|
||||
ItemPointerSetOffsetNumber(&target_tid, xlrec->offnum);
|
||||
|
||||
@ -9020,7 +9020,7 @@ heap_xlog_delete(XLogReaderState *record)
|
||||
*/
|
||||
if (xlrec->flags & XLH_DELETE_ALL_VISIBLE_CLEARED)
|
||||
{
|
||||
Relation reln = CreateFakeRelcacheEntry(target_node);
|
||||
Relation reln = CreateFakeRelcacheEntry(target_locator);
|
||||
Buffer vmbuffer = InvalidBuffer;
|
||||
|
||||
visibilitymap_pin(reln, blkno, &vmbuffer);
|
||||
@ -9086,12 +9086,12 @@ heap_xlog_insert(XLogReaderState *record)
|
||||
xl_heap_header xlhdr;
|
||||
uint32 newlen;
|
||||
Size freespace = 0;
|
||||
RelFileNode target_node;
|
||||
RelFileLocator target_locator;
|
||||
BlockNumber blkno;
|
||||
ItemPointerData target_tid;
|
||||
XLogRedoAction action;
|
||||
|
||||
XLogRecGetBlockTag(record, 0, &target_node, NULL, &blkno);
|
||||
XLogRecGetBlockTag(record, 0, &target_locator, NULL, &blkno);
|
||||
ItemPointerSetBlockNumber(&target_tid, blkno);
|
||||
ItemPointerSetOffsetNumber(&target_tid, xlrec->offnum);
|
||||
|
||||
@ -9101,7 +9101,7 @@ heap_xlog_insert(XLogReaderState *record)
|
||||
*/
|
||||
if (xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED)
|
||||
{
|
||||
Relation reln = CreateFakeRelcacheEntry(target_node);
|
||||
Relation reln = CreateFakeRelcacheEntry(target_locator);
|
||||
Buffer vmbuffer = InvalidBuffer;
|
||||
|
||||
visibilitymap_pin(reln, blkno, &vmbuffer);
|
||||
@ -9184,7 +9184,7 @@ heap_xlog_insert(XLogReaderState *record)
|
||||
* totally accurate anyway.
|
||||
*/
|
||||
if (action == BLK_NEEDS_REDO && freespace < BLCKSZ / 5)
|
||||
XLogRecordPageWithFreeSpace(target_node, blkno, freespace);
|
||||
XLogRecordPageWithFreeSpace(target_locator, blkno, freespace);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -9195,7 +9195,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
|
||||
{
|
||||
XLogRecPtr lsn = record->EndRecPtr;
|
||||
xl_heap_multi_insert *xlrec;
|
||||
RelFileNode rnode;
|
||||
RelFileLocator rlocator;
|
||||
BlockNumber blkno;
|
||||
Buffer buffer;
|
||||
Page page;
|
||||
@ -9217,7 +9217,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
|
||||
*/
|
||||
xlrec = (xl_heap_multi_insert *) XLogRecGetData(record);
|
||||
|
||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno);
|
||||
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &blkno);
|
||||
|
||||
/* check that the mutually exclusive flags are not both set */
|
||||
Assert(!((xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED) &&
|
||||
@ -9229,7 +9229,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
|
||||
*/
|
||||
if (xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED)
|
||||
{
|
||||
Relation reln = CreateFakeRelcacheEntry(rnode);
|
||||
Relation reln = CreateFakeRelcacheEntry(rlocator);
|
||||
Buffer vmbuffer = InvalidBuffer;
|
||||
|
||||
visibilitymap_pin(reln, blkno, &vmbuffer);
|
||||
@ -9331,7 +9331,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
|
||||
* totally accurate anyway.
|
||||
*/
|
||||
if (action == BLK_NEEDS_REDO && freespace < BLCKSZ / 5)
|
||||
XLogRecordPageWithFreeSpace(rnode, blkno, freespace);
|
||||
XLogRecordPageWithFreeSpace(rlocator, blkno, freespace);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -9342,7 +9342,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
||||
{
|
||||
XLogRecPtr lsn = record->EndRecPtr;
|
||||
xl_heap_update *xlrec = (xl_heap_update *) XLogRecGetData(record);
|
||||
RelFileNode rnode;
|
||||
RelFileLocator rlocator;
|
||||
BlockNumber oldblk;
|
||||
BlockNumber newblk;
|
||||
ItemPointerData newtid;
|
||||
@ -9371,7 +9371,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
||||
oldtup.t_data = NULL;
|
||||
oldtup.t_len = 0;
|
||||
|
||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &newblk);
|
||||
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &newblk);
|
||||
if (XLogRecGetBlockTagExtended(record, 1, NULL, NULL, &oldblk, NULL))
|
||||
{
|
||||
/* HOT updates are never done across pages */
|
||||
@ -9388,7 +9388,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
||||
*/
|
||||
if (xlrec->flags & XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED)
|
||||
{
|
||||
Relation reln = CreateFakeRelcacheEntry(rnode);
|
||||
Relation reln = CreateFakeRelcacheEntry(rlocator);
|
||||
Buffer vmbuffer = InvalidBuffer;
|
||||
|
||||
visibilitymap_pin(reln, oldblk, &vmbuffer);
|
||||
@ -9472,7 +9472,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
||||
*/
|
||||
if (xlrec->flags & XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED)
|
||||
{
|
||||
Relation reln = CreateFakeRelcacheEntry(rnode);
|
||||
Relation reln = CreateFakeRelcacheEntry(rlocator);
|
||||
Buffer vmbuffer = InvalidBuffer;
|
||||
|
||||
visibilitymap_pin(reln, newblk, &vmbuffer);
|
||||
@ -9606,7 +9606,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
||||
* totally accurate anyway.
|
||||
*/
|
||||
if (newaction == BLK_NEEDS_REDO && !hot_update && freespace < BLCKSZ / 5)
|
||||
XLogRecordPageWithFreeSpace(rnode, newblk, freespace);
|
||||
XLogRecordPageWithFreeSpace(rlocator, newblk, freespace);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -9662,13 +9662,13 @@ heap_xlog_lock(XLogReaderState *record)
|
||||
*/
|
||||
if (xlrec->flags & XLH_LOCK_ALL_FROZEN_CLEARED)
|
||||
{
|
||||
RelFileNode rnode;
|
||||
RelFileLocator rlocator;
|
||||
Buffer vmbuffer = InvalidBuffer;
|
||||
BlockNumber block;
|
||||
Relation reln;
|
||||
|
||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &block);
|
||||
reln = CreateFakeRelcacheEntry(rnode);
|
||||
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &block);
|
||||
reln = CreateFakeRelcacheEntry(rlocator);
|
||||
|
||||
visibilitymap_pin(reln, block, &vmbuffer);
|
||||
visibilitymap_clear(reln, block, vmbuffer, VISIBILITYMAP_ALL_FROZEN);
|
||||
@ -9735,13 +9735,13 @@ heap_xlog_lock_updated(XLogReaderState *record)
|
||||
*/
|
||||
if (xlrec->flags & XLH_LOCK_ALL_FROZEN_CLEARED)
|
||||
{
|
||||
RelFileNode rnode;
|
||||
RelFileLocator rlocator;
|
||||
Buffer vmbuffer = InvalidBuffer;
|
||||
BlockNumber block;
|
||||
Relation reln;
|
||||
|
||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &block);
|
||||
reln = CreateFakeRelcacheEntry(rnode);
|
||||
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &block);
|
||||
reln = CreateFakeRelcacheEntry(rlocator);
|
||||
|
||||
visibilitymap_pin(reln, block, &vmbuffer);
|
||||
visibilitymap_clear(reln, block, vmbuffer, VISIBILITYMAP_ALL_FROZEN);
|
||||
|
Reference in New Issue
Block a user