aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/dbsize.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/utils/adt/dbsize.c
parent7775c748db1257523ecbed1060dadb608bdff6de (diff)
downloadpostgresql-b0a55e43299c4ea2a9a8c757f9c26352407d0ccc.tar.gz
postgresql-b0a55e43299c4ea2a9a8c757f9c26352407d0ccc.zip
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/utils/adt/dbsize.c')
-rw-r--r--src/backend/utils/adt/dbsize.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index b4a2c8d2197..34efa121b40 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -27,7 +27,7 @@
#include "utils/builtins.h"
#include "utils/numeric.h"
#include "utils/rel.h"
-#include "utils/relfilenodemap.h"
+#include "utils/relfilenumbermap.h"
#include "utils/relmapper.h"
#include "utils/syscache.h"
@@ -292,7 +292,7 @@ pg_tablespace_size_name(PG_FUNCTION_ARGS)
* is no check here or at the call sites for that.
*/
static int64
-calculate_relation_size(RelFileNode *rfn, BackendId backend, ForkNumber forknum)
+calculate_relation_size(RelFileLocator *rfn, BackendId backend, ForkNumber forknum)
{
int64 totalsize = 0;
char *relationpath;
@@ -349,7 +349,7 @@ pg_relation_size(PG_FUNCTION_ARGS)
if (rel == NULL)
PG_RETURN_NULL();
- size = calculate_relation_size(&(rel->rd_node), rel->rd_backend,
+ size = calculate_relation_size(&(rel->rd_locator), rel->rd_backend,
forkname_to_number(text_to_cstring(forkName)));
relation_close(rel, AccessShareLock);
@@ -374,7 +374,7 @@ calculate_toast_table_size(Oid toastrelid)
/* toast heap size, including FSM and VM size */
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
- size += calculate_relation_size(&(toastRel->rd_node),
+ size += calculate_relation_size(&(toastRel->rd_locator),
toastRel->rd_backend, forkNum);
/* toast index size, including FSM and VM size */
@@ -388,7 +388,7 @@ calculate_toast_table_size(Oid toastrelid)
toastIdxRel = relation_open(lfirst_oid(lc),
AccessShareLock);
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
- size += calculate_relation_size(&(toastIdxRel->rd_node),
+ size += calculate_relation_size(&(toastIdxRel->rd_locator),
toastIdxRel->rd_backend, forkNum);
relation_close(toastIdxRel, AccessShareLock);
@@ -417,7 +417,7 @@ calculate_table_size(Relation rel)
* heap size, including FSM and VM
*/
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
- size += calculate_relation_size(&(rel->rd_node), rel->rd_backend,
+ size += calculate_relation_size(&(rel->rd_locator), rel->rd_backend,
forkNum);
/*
@@ -456,7 +456,7 @@ calculate_indexes_size(Relation rel)
idxRel = relation_open(idxOid, AccessShareLock);
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
- size += calculate_relation_size(&(idxRel->rd_node),
+ size += calculate_relation_size(&(idxRel->rd_locator),
idxRel->rd_backend,
forkNum);
@@ -850,7 +850,7 @@ Datum
pg_relation_filenode(PG_FUNCTION_ARGS)
{
Oid relid = PG_GETARG_OID(0);
- Oid result;
+ RelFileNumber result;
HeapTuple tuple;
Form_pg_class relform;
@@ -864,29 +864,29 @@ pg_relation_filenode(PG_FUNCTION_ARGS)
if (relform->relfilenode)
result = relform->relfilenode;
else /* Consult the relation mapper */
- result = RelationMapOidToFilenode(relid,
- relform->relisshared);
+ result = RelationMapOidToFilenumber(relid,
+ relform->relisshared);
}
else
{
/* no storage, return NULL */
- result = InvalidOid;
+ result = InvalidRelFileNumber;
}
ReleaseSysCache(tuple);
- if (!OidIsValid(result))
+ if (!RelFileNumberIsValid(result))
PG_RETURN_NULL();
PG_RETURN_OID(result);
}
/*
- * Get the relation via (reltablespace, relfilenode)
+ * Get the relation via (reltablespace, relfilenumber)
*
* This is expected to be used when somebody wants to match an individual file
* on the filesystem back to its table. That's not trivially possible via
- * pg_class, because that doesn't contain the relfilenodes of shared and nailed
+ * pg_class, because that doesn't contain the relfilenumbers of shared and nailed
* tables.
*
* We don't fail but return NULL if we cannot find a mapping.
@@ -898,14 +898,14 @@ Datum
pg_filenode_relation(PG_FUNCTION_ARGS)
{
Oid reltablespace = PG_GETARG_OID(0);
- Oid relfilenode = PG_GETARG_OID(1);
+ RelFileNumber relfilenumber = PG_GETARG_OID(1);
Oid heaprel;
- /* test needed so RelidByRelfilenode doesn't misbehave */
- if (!OidIsValid(relfilenode))
+ /* test needed so RelidByRelfilenumber doesn't misbehave */
+ if (!RelFileNumberIsValid(relfilenumber))
PG_RETURN_NULL();
- heaprel = RelidByRelfilenode(reltablespace, relfilenode);
+ heaprel = RelidByRelfilenumber(reltablespace, relfilenumber);
if (!OidIsValid(heaprel))
PG_RETURN_NULL();
@@ -924,7 +924,7 @@ pg_relation_filepath(PG_FUNCTION_ARGS)
Oid relid = PG_GETARG_OID(0);
HeapTuple tuple;
Form_pg_class relform;
- RelFileNode rnode;
+ RelFileLocator rlocator;
BackendId backend;
char *path;
@@ -937,29 +937,29 @@ pg_relation_filepath(PG_FUNCTION_ARGS)
{
/* This logic should match RelationInitPhysicalAddr */
if (relform->reltablespace)
- rnode.spcNode = relform->reltablespace;
+ rlocator.spcOid = relform->reltablespace;
else
- rnode.spcNode = MyDatabaseTableSpace;
- if (rnode.spcNode == GLOBALTABLESPACE_OID)
- rnode.dbNode = InvalidOid;
+ rlocator.spcOid = MyDatabaseTableSpace;
+ if (rlocator.spcOid == GLOBALTABLESPACE_OID)
+ rlocator.dbOid = InvalidOid;
else
- rnode.dbNode = MyDatabaseId;
+ rlocator.dbOid = MyDatabaseId;
if (relform->relfilenode)
- rnode.relNode = relform->relfilenode;
+ rlocator.relNumber = relform->relfilenode;
else /* Consult the relation mapper */
- rnode.relNode = RelationMapOidToFilenode(relid,
- relform->relisshared);
+ rlocator.relNumber = RelationMapOidToFilenumber(relid,
+ relform->relisshared);
}
else
{
/* no storage, return NULL */
- rnode.relNode = InvalidOid;
+ rlocator.relNumber = InvalidRelFileNumber;
/* some compilers generate warnings without these next two lines */
- rnode.dbNode = InvalidOid;
- rnode.spcNode = InvalidOid;
+ rlocator.dbOid = InvalidOid;
+ rlocator.spcOid = InvalidOid;
}
- if (!OidIsValid(rnode.relNode))
+ if (!RelFileNumberIsValid(rlocator.relNumber))
{
ReleaseSysCache(tuple);
PG_RETURN_NULL();
@@ -990,7 +990,7 @@ pg_relation_filepath(PG_FUNCTION_ARGS)
ReleaseSysCache(tuple);
- path = relpathbackend(rnode, backend, MAIN_FORKNUM);
+ path = relpathbackend(rlocator, backend, MAIN_FORKNUM);
PG_RETURN_TEXT_P(cstring_to_text(path));
}