diff options
| author | Robert Haas | 2022-07-06 15:39:09 +0000 |
|---|---|---|
| committer | Robert Haas | 2022-07-06 15:39:09 +0000 |
| commit | b0a55e43299c4ea2a9a8c757f9c26352407d0ccc (patch) | |
| tree | 2c22c2965f9976ae4469595cd28df13db6b943c2 /src/include/utils | |
| parent | 7775c748db1257523ecbed1060dadb608bdff6de (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/include/utils')
| -rw-r--r-- | src/include/utils/inval.h | 4 | ||||
| -rw-r--r-- | src/include/utils/rel.h | 47 | ||||
| -rw-r--r-- | src/include/utils/relcache.h | 8 | ||||
| -rw-r--r-- | src/include/utils/relfilenumbermap.h (renamed from src/include/utils/relfilenodemap.h) | 15 | ||||
| -rw-r--r-- | src/include/utils/relmapper.h | 13 |
5 files changed, 45 insertions, 42 deletions
diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h index 0e0323b91a0..23748b72caf 100644 --- a/src/include/utils/inval.h +++ b/src/include/utils/inval.h @@ -15,7 +15,7 @@ #define INVAL_H #include "access/htup.h" -#include "storage/relfilenode.h" +#include "storage/relfilelocator.h" #include "utils/relcache.h" extern PGDLLIMPORT int debug_discard_caches; @@ -48,7 +48,7 @@ extern void CacheInvalidateRelcacheByTuple(HeapTuple classTuple); extern void CacheInvalidateRelcacheByRelid(Oid relid); -extern void CacheInvalidateSmgr(RelFileNodeBackend rnode); +extern void CacheInvalidateSmgr(RelFileLocatorBackend rlocator); extern void CacheInvalidateRelmap(Oid databaseId); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 1896a9a06d1..8231fba9a3d 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -23,7 +23,7 @@ #include "partitioning/partdefs.h" #include "rewrite/prs2lock.h" #include "storage/block.h" -#include "storage/relfilenode.h" +#include "storage/relfilelocator.h" #include "storage/smgr.h" #include "utils/relcache.h" #include "utils/reltrigger.h" @@ -53,7 +53,7 @@ typedef LockInfoData *LockInfo; typedef struct RelationData { - RelFileNode rd_node; /* relation physical identifier */ + RelFileLocator rd_locator; /* relation physical identifier */ SMgrRelation rd_smgr; /* cached file handle, or NULL */ int rd_refcnt; /* reference count */ BackendId rd_backend; /* owning backend id, if temporary relation */ @@ -66,44 +66,45 @@ typedef struct RelationData /*---------- * rd_createSubid is the ID of the highest subtransaction the rel has - * survived into or zero if the rel or its rd_node was created before the - * current top transaction. (IndexStmt.oldNode leads to the case of a new - * rel with an old rd_node.) rd_firstRelfilenodeSubid is the ID of the - * highest subtransaction an rd_node change has survived into or zero if - * rd_node matches the value it had at the start of the current top + * survived into or zero if the rel or its storage was created before the + * current top transaction. (IndexStmt.oldNumber leads to the case of a new + * rel with an old rd_locator.) rd_firstRelfilelocatorSubid is the ID of the + * highest subtransaction an rd_locator change has survived into or zero if + * rd_locator matches the value it had at the start of the current top * transaction. (Rolling back the subtransaction that - * rd_firstRelfilenodeSubid denotes would restore rd_node to the value it + * rd_firstRelfilelocatorSubid denotes would restore rd_locator to the value it * had at the start of the current top transaction. Rolling back any * lower subtransaction would not.) Their accuracy is critical to * RelationNeedsWAL(). * - * rd_newRelfilenodeSubid is the ID of the highest subtransaction the - * most-recent relfilenode change has survived into or zero if not changed + * rd_newRelfilelocatorSubid is the ID of the highest subtransaction the + * most-recent relfilenumber change has survived into or zero if not changed * in the current transaction (or we have forgotten changing it). This * field is accurate when non-zero, but it can be zero when a relation has - * multiple new relfilenodes within a single transaction, with one of them + * multiple new relfilenumbers within a single transaction, with one of them * occurring in a subsequently aborted subtransaction, e.g. * BEGIN; * TRUNCATE t; * SAVEPOINT save; * TRUNCATE t; * ROLLBACK TO save; - * -- rd_newRelfilenodeSubid is now forgotten + * -- rd_newRelfilelocatorSubid is now forgotten * * If every rd_*Subid field is zero, they are read-only outside - * relcache.c. Files that trigger rd_node changes by updating + * relcache.c. Files that trigger rd_locator changes by updating * pg_class.reltablespace and/or pg_class.relfilenode call - * RelationAssumeNewRelfilenode() to update rd_*Subid. + * RelationAssumeNewRelfilelocator() to update rd_*Subid. * * rd_droppedSubid is the ID of the highest subtransaction that a drop of * the rel has survived into. In entries visible outside relcache.c, this * is always zero. */ SubTransactionId rd_createSubid; /* rel was created in current xact */ - SubTransactionId rd_newRelfilenodeSubid; /* highest subxact changing - * rd_node to current value */ - SubTransactionId rd_firstRelfilenodeSubid; /* highest subxact changing - * rd_node to any value */ + SubTransactionId rd_newRelfilelocatorSubid; /* highest subxact changing + * rd_locator to current value */ + SubTransactionId rd_firstRelfilelocatorSubid; /* highest subxact + * changing rd_locator to + * any value */ SubTransactionId rd_droppedSubid; /* dropped with another Subid set */ Form_pg_class rd_rel; /* RELATION tuple */ @@ -531,12 +532,12 @@ typedef struct ViewOptions /* * RelationIsMapped - * True if the relation uses the relfilenode map. Note multiple eval + * True if the relation uses the relfilenumber map. Note multiple eval * of argument! */ #define RelationIsMapped(relation) \ (RELKIND_HAS_STORAGE((relation)->rd_rel->relkind) && \ - ((relation)->rd_rel->relfilenode == InvalidOid)) + ((relation)->rd_rel->relfilenode == InvalidRelFileNumber)) /* * RelationGetSmgr @@ -555,7 +556,7 @@ static inline SMgrRelation RelationGetSmgr(Relation rel) { if (unlikely(rel->rd_smgr == NULL)) - smgrsetowner(&(rel->rd_smgr), smgropen(rel->rd_node, rel->rd_backend)); + smgrsetowner(&(rel->rd_smgr), smgropen(rel->rd_locator, rel->rd_backend)); return rel->rd_smgr; } @@ -607,12 +608,12 @@ RelationGetSmgr(Relation rel) * * Returns false if wal_level = minimal and this relation is created or * truncated in the current transaction. See "Skipping WAL for New - * RelFileNode" in src/backend/access/transam/README. + * RelFileLocator" in src/backend/access/transam/README. */ #define RelationNeedsWAL(relation) \ (RelationIsPermanent(relation) && (XLogIsNeeded() || \ (relation->rd_createSubid == InvalidSubTransactionId && \ - relation->rd_firstRelfilenodeSubid == InvalidSubTransactionId))) + relation->rd_firstRelfilelocatorSubid == InvalidSubTransactionId))) /* * RelationUsesLocalBuffers diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index c93d8654bb9..ba35d6b3b3c 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -103,7 +103,7 @@ extern Relation RelationBuildLocalRelation(const char *relname, TupleDesc tupDesc, Oid relid, Oid accessmtd, - Oid relfilenode, + RelFileNumber relfilenumber, Oid reltablespace, bool shared_relation, bool mapped_relation, @@ -111,10 +111,10 @@ extern Relation RelationBuildLocalRelation(const char *relname, char relkind); /* - * Routines to manage assignment of new relfilenode to a relation + * Routines to manage assignment of new relfilenumber to a relation */ -extern void RelationSetNewRelfilenode(Relation relation, char persistence); -extern void RelationAssumeNewRelfilenode(Relation relation); +extern void RelationSetNewRelfilenumber(Relation relation, char persistence); +extern void RelationAssumeNewRelfilelocator(Relation relation); /* * Routines for flushing/rebuilding relcache entries in various scenarios diff --git a/src/include/utils/relfilenodemap.h b/src/include/utils/relfilenumbermap.h index 77d8046505e..c149a937e92 100644 --- a/src/include/utils/relfilenodemap.h +++ b/src/include/utils/relfilenumbermap.h @@ -1,18 +1,19 @@ /*------------------------------------------------------------------------- * - * relfilenodemap.h - * relfilenode to oid mapping cache. + * relfilenumbermap.h + * relfilenumber to oid mapping cache. * * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * src/include/utils/relfilenodemap.h + * src/include/utils/relfilenumbermap.h * *------------------------------------------------------------------------- */ -#ifndef RELFILENODEMAP_H -#define RELFILENODEMAP_H +#ifndef RELFILENUMBERMAP_H +#define RELFILENUMBERMAP_H -extern Oid RelidByRelfilenode(Oid reltablespace, Oid relfilenode); +extern Oid RelidByRelfilenumber(Oid reltablespace, + RelFileNumber relfilenumber); -#endif /* RELFILENODEMAP_H */ +#endif /* RELFILENUMBERMAP_H */ diff --git a/src/include/utils/relmapper.h b/src/include/utils/relmapper.h index 557f77e35a9..2bb2e255fdb 100644 --- a/src/include/utils/relmapper.h +++ b/src/include/utils/relmapper.h @@ -1,7 +1,7 @@ /*------------------------------------------------------------------------- * * relmapper.h - * Catalog-to-filenode mapping + * Catalog-to-filenumber mapping * * * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group @@ -35,14 +35,15 @@ typedef struct xl_relmap_update #define MinSizeOfRelmapUpdate offsetof(xl_relmap_update, data) -extern Oid RelationMapOidToFilenode(Oid relationId, bool shared); +extern RelFileNumber RelationMapOidToFilenumber(Oid relationId, bool shared); -extern Oid RelationMapFilenodeToOid(Oid relationId, bool shared); -extern Oid RelationMapOidToFilenodeForDatabase(char *dbpath, Oid relationId); +extern Oid RelationMapFilenumberToOid(RelFileNumber relationId, bool shared); +extern RelFileNumber RelationMapOidToFilenumberForDatabase(char *dbpath, + Oid relationId); extern void RelationMapCopy(Oid dbid, Oid tsid, char *srcdbpath, char *dstdbpath); -extern void RelationMapUpdateMap(Oid relationId, Oid fileNode, bool shared, - bool immediate); +extern void RelationMapUpdateMap(Oid relationId, RelFileNumber fileNumber, + bool shared, bool immediate); extern void RelationMapRemoveMapping(Oid relationId); |
