summaryrefslogtreecommitdiff
path: root/src/backend/replication/logical/reorderbuffer.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2022-07-06 11:39:09 -0400
committerRobert Haas <rhaas@postgresql.org>2022-07-06 11:39:09 -0400
commitb0a55e43299c4ea2a9a8c757f9c26352407d0ccc (patch)
tree2c22c2965f9976ae4469595cd28df13db6b943c2 /src/backend/replication/logical/reorderbuffer.c
parent7775c748db1257523ecbed1060dadb608bdff6de (diff)
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
Diffstat (limited to 'src/backend/replication/logical/reorderbuffer.c')
-rw-r--r--src/backend/replication/logical/reorderbuffer.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 8da5f9089c7..88a37fde722 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -106,7 +106,7 @@
#include "utils/memdebug.h"
#include "utils/memutils.h"
#include "utils/rel.h"
-#include "utils/relfilenodemap.h"
+#include "utils/relfilenumbermap.h"
/* entry for a hash table we use to map from xid to our transaction state */
@@ -116,10 +116,10 @@ typedef struct ReorderBufferTXNByIdEnt
ReorderBufferTXN *txn;
} ReorderBufferTXNByIdEnt;
-/* data structures for (relfilenode, ctid) => (cmin, cmax) mapping */
+/* data structures for (relfilelocator, ctid) => (cmin, cmax) mapping */
typedef struct ReorderBufferTupleCidKey
{
- RelFileNode relnode;
+ RelFileLocator rlocator;
ItemPointerData tid;
} ReorderBufferTupleCidKey;
@@ -1643,7 +1643,7 @@ ReorderBufferTruncateTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, bool txn_prep
}
/*
- * Destroy the (relfilenode, ctid) hashtable, so that we don't leak any
+ * Destroy the (relfilelocator, ctid) hashtable, so that we don't leak any
* memory. We could also keep the hash table and update it with new ctid
* values, but this seems simpler and good enough for now.
*/
@@ -1673,7 +1673,7 @@ ReorderBufferTruncateTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, bool txn_prep
}
/*
- * Build a hash with a (relfilenode, ctid) -> (cmin, cmax) mapping for use by
+ * Build a hash with a (relfilelocator, ctid) -> (cmin, cmax) mapping for use by
* HeapTupleSatisfiesHistoricMVCC.
*/
static void
@@ -1711,7 +1711,7 @@ ReorderBufferBuildTupleCidHash(ReorderBuffer *rb, ReorderBufferTXN *txn)
/* be careful about padding */
memset(&key, 0, sizeof(ReorderBufferTupleCidKey));
- key.relnode = change->data.tuplecid.node;
+ key.rlocator = change->data.tuplecid.locator;
ItemPointerCopy(&change->data.tuplecid.tid,
&key.tid);
@@ -2140,36 +2140,36 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn,
case REORDER_BUFFER_CHANGE_DELETE:
Assert(snapshot_now);
- reloid = RelidByRelfilenode(change->data.tp.relnode.spcNode,
- change->data.tp.relnode.relNode);
+ reloid = RelidByRelfilenumber(change->data.tp.rlocator.spcOid,
+ change->data.tp.rlocator.relNumber);
/*
* Mapped catalog tuple without data, emitted while
* catalog table was in the process of being rewritten. We
- * can fail to look up the relfilenode, because the
+ * can fail to look up the relfilenumber, because the
* relmapper has no "historic" view, in contrast to the
* normal catalog during decoding. Thus repeated rewrites
* can cause a lookup failure. That's OK because we do not
* decode catalog changes anyway. Normally such tuples
* would be skipped over below, but we can't identify
* whether the table should be logically logged without
- * mapping the relfilenode to the oid.
+ * mapping the relfilenumber to the oid.
*/
if (reloid == InvalidOid &&
change->data.tp.newtuple == NULL &&
change->data.tp.oldtuple == NULL)
goto change_done;
else if (reloid == InvalidOid)
- elog(ERROR, "could not map filenode \"%s\" to relation OID",
- relpathperm(change->data.tp.relnode,
+ elog(ERROR, "could not map filenumber \"%s\" to relation OID",
+ relpathperm(change->data.tp.rlocator,
MAIN_FORKNUM));
relation = RelationIdGetRelation(reloid);
if (!RelationIsValid(relation))
- elog(ERROR, "could not open relation with OID %u (for filenode \"%s\")",
+ elog(ERROR, "could not open relation with OID %u (for filenumber \"%s\")",
reloid,
- relpathperm(change->data.tp.relnode,
+ relpathperm(change->data.tp.rlocator,
MAIN_FORKNUM));
if (!RelationIsLogicallyLogged(relation))
@@ -3157,7 +3157,7 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
}
/*
- * Add new (relfilenode, tid) -> (cmin, cmax) mappings.
+ * Add new (relfilelocator, tid) -> (cmin, cmax) mappings.
*
* We do not include this change type in memory accounting, because we
* keep CIDs in a separate list and do not evict them when reaching
@@ -3165,7 +3165,7 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
*/
void
ReorderBufferAddNewTupleCids(ReorderBuffer *rb, TransactionId xid,
- XLogRecPtr lsn, RelFileNode node,
+ XLogRecPtr lsn, RelFileLocator locator,
ItemPointerData tid, CommandId cmin,
CommandId cmax, CommandId combocid)
{
@@ -3174,7 +3174,7 @@ ReorderBufferAddNewTupleCids(ReorderBuffer *rb, TransactionId xid,
txn = ReorderBufferTXNByXid(rb, xid, true, NULL, lsn, true);
- change->data.tuplecid.node = node;
+ change->data.tuplecid.locator = locator;
change->data.tuplecid.tid = tid;
change->data.tuplecid.cmin = cmin;
change->data.tuplecid.cmax = cmax;
@@ -4839,7 +4839,7 @@ ReorderBufferToastReset(ReorderBuffer *rb, ReorderBufferTXN *txn)
* need anymore.
*
* To resolve those problems we have a per-transaction hash of (cmin,
- * cmax) tuples keyed by (relfilenode, ctid) which contains the actual
+ * cmax) tuples keyed by (relfilelocator, ctid) which contains the actual
* (cmin, cmax) values. That also takes care of combo CIDs by simply
* not caring about them at all. As we have the real cmin/cmax values
* combo CIDs aren't interesting.
@@ -4870,9 +4870,9 @@ DisplayMapping(HTAB *tuplecid_data)
while ((ent = (ReorderBufferTupleCidEnt *) hash_seq_search(&hstat)) != NULL)
{
elog(DEBUG3, "mapping: node: %u/%u/%u tid: %u/%u cmin: %u, cmax: %u",
- ent->key.relnode.dbNode,
- ent->key.relnode.spcNode,
- ent->key.relnode.relNode,
+ ent->key.rlocator.dbOid,
+ ent->key.rlocator.spcOid,
+ ent->key.rlocator.relNumber,
ItemPointerGetBlockNumber(&ent->key.tid),
ItemPointerGetOffsetNumber(&ent->key.tid),
ent->cmin,
@@ -4932,7 +4932,7 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid, const char *fname)
path, readBytes,
(int32) sizeof(LogicalRewriteMappingData))));
- key.relnode = map.old_node;
+ key.rlocator = map.old_locator;
ItemPointerCopy(&map.old_tid,
&key.tid);
@@ -4947,7 +4947,7 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid, const char *fname)
if (!ent)
continue;
- key.relnode = map.new_node;
+ key.rlocator = map.new_locator;
ItemPointerCopy(&map.new_tid,
&key.tid);
@@ -5120,10 +5120,10 @@ ResolveCminCmaxDuringDecoding(HTAB *tuplecid_data,
Assert(!BufferIsLocal(buffer));
/*
- * get relfilenode from the buffer, no convenient way to access it other
- * than that.
+ * get relfilelocator from the buffer, no convenient way to access it
+ * other than that.
*/
- BufferGetTag(buffer, &key.relnode, &forkno, &blockno);
+ BufferGetTag(buffer, &key.rlocator, &forkno, &blockno);
/* tuples can only be in the main fork */
Assert(forkno == MAIN_FORKNUM);