aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-03-03 19:38:22 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-03-03 19:38:22 +0200
commit024c521117579a6d356050ad3d78fdc95e44eefa (patch)
tree27a2d9588eefc43c4bc3ac7b31f8a6740a2de34b /src/backend/utils/cache
parentab355e3a88de745607f6dd4c21f0119b5c68f2ad (diff)
downloadpostgresql-024c521117579a6d356050ad3d78fdc95e44eefa.tar.gz
postgresql-024c521117579a6d356050ad3d78fdc95e44eefa.zip
Replace BackendIds with 0-based ProcNumbers
Now that BackendId was just another index into the proc array, it was redundant with the 0-based proc numbers used in other places. Replace all usage of backend IDs with proc numbers. The only place where the term "backend id" remains is in a few pgstat functions that expose backend IDs at the SQL level. Those IDs are now in fact 0-based ProcNumbers too, but the documentation still calls them "backend ids". That term still seems appropriate to describe what the numbers are, so I let it be. One user-visible effect is that pg_temp_0 is now a valid temp schema name, for backend with ProcNumber 0. Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/message-id/8171f1aa-496f-46a6-afc3-c46fe7a9b407@iki.fi
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r--src/backend/utils/cache/inval.c4
-rw-r--r--src/backend/utils/cache/relcache.c30
2 files changed, 17 insertions, 17 deletions
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index f59b07a70f8..816b883b6da 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -1453,8 +1453,8 @@ CacheInvalidateRelcacheByRelid(Oid relid)
* replaying WAL as well as when creating it.
*
* Note: In order to avoid bloating SharedInvalidationMessage, we store only
- * three bytes of the backend ID using what would otherwise be padding space.
- * Thus, the maximum possible backend ID is 2^23-1.
+ * three bytes of the ProcNumber using what would otherwise be padding space.
+ * Thus, the maximum possible ProcNumber is 2^23-1.
*/
void
CacheInvalidateSmgr(RelFileLocatorBackend rlocator)
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 50acae45298..37c37df56c1 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -1144,13 +1144,13 @@ retry:
{
case RELPERSISTENCE_UNLOGGED:
case RELPERSISTENCE_PERMANENT:
- relation->rd_backend = InvalidBackendId;
+ relation->rd_backend = INVALID_PROC_NUMBER;
relation->rd_islocaltemp = false;
break;
case RELPERSISTENCE_TEMP:
if (isTempOrTempToastNamespace(relation->rd_rel->relnamespace))
{
- relation->rd_backend = BackendIdForTempRelations();
+ relation->rd_backend = ProcNumberForTempRelations();
relation->rd_islocaltemp = true;
}
else
@@ -1159,18 +1159,18 @@ retry:
* If it's a temp table, but not one of ours, we have to use
* the slow, grotty method to figure out the owning backend.
*
- * Note: it's possible that rd_backend gets set to MyBackendId
- * here, in case we are looking at a pg_class entry left over
- * from a crashed backend that coincidentally had the same
- * BackendId we're using. We should *not* consider such a
- * table to be "ours"; this is why we need the separate
- * rd_islocaltemp flag. The pg_class entry will get flushed
- * if/when we clean out the corresponding temp table namespace
- * in preparation for using it.
+ * Note: it's possible that rd_backend gets set to
+ * MyProcNumber here, in case we are looking at a pg_class
+ * entry left over from a crashed backend that coincidentally
+ * had the same ProcNumber we're using. We should *not*
+ * consider such a table to be "ours"; this is why we need the
+ * separate rd_islocaltemp flag. The pg_class entry will get
+ * flushed if/when we clean out the corresponding temp table
+ * namespace in preparation for using it.
*/
relation->rd_backend =
- GetTempNamespaceBackendId(relation->rd_rel->relnamespace);
- Assert(relation->rd_backend != InvalidBackendId);
+ GetTempNamespaceProcNumber(relation->rd_rel->relnamespace);
+ Assert(relation->rd_backend != INVALID_PROC_NUMBER);
relation->rd_islocaltemp = false;
}
break;
@@ -1896,7 +1896,7 @@ formrdesc(const char *relationName, Oid relationReltype,
relation->rd_newRelfilelocatorSubid = InvalidSubTransactionId;
relation->rd_firstRelfilelocatorSubid = InvalidSubTransactionId;
relation->rd_droppedSubid = InvalidSubTransactionId;
- relation->rd_backend = InvalidBackendId;
+ relation->rd_backend = INVALID_PROC_NUMBER;
relation->rd_islocaltemp = false;
/*
@@ -3611,12 +3611,12 @@ RelationBuildLocalRelation(const char *relname,
{
case RELPERSISTENCE_UNLOGGED:
case RELPERSISTENCE_PERMANENT:
- rel->rd_backend = InvalidBackendId;
+ rel->rd_backend = INVALID_PROC_NUMBER;
rel->rd_islocaltemp = false;
break;
case RELPERSISTENCE_TEMP:
Assert(isTempOrTempToastNamespace(relnamespace));
- rel->rd_backend = BackendIdForTempRelations();
+ rel->rd_backend = ProcNumberForTempRelations();
rel->rd_islocaltemp = true;
break;
default: