mirror of
https://github.com/postgres/postgres.git
synced 2025-09-11 00:12:06 +03:00
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
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "catalog/pg_tablespace_d.h"
|
||||
#include "common/relpath.h"
|
||||
#include "storage/backendid.h"
|
||||
#include "storage/procnumber.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -133,13 +133,13 @@ GetDatabasePath(Oid dbOid, Oid spcOid)
|
||||
*
|
||||
* Result is a palloc'd string.
|
||||
*
|
||||
* Note: ideally, backendId would be declared as type BackendId, but relpath.h
|
||||
* would have to include a backend-only header to do that; doesn't seem worth
|
||||
* the trouble considering BackendId is just int anyway.
|
||||
* Note: ideally, procNumber would be declared as type ProcNumber, but
|
||||
* relpath.h would have to include a backend-only header to do that; doesn't
|
||||
* seem worth the trouble considering ProcNumber is just int anyway.
|
||||
*/
|
||||
char *
|
||||
GetRelationPath(Oid dbOid, Oid spcOid, RelFileNumber relNumber,
|
||||
int backendId, ForkNumber forkNumber)
|
||||
int procNumber, ForkNumber forkNumber)
|
||||
{
|
||||
char *path;
|
||||
|
||||
@@ -147,7 +147,7 @@ GetRelationPath(Oid dbOid, Oid spcOid, RelFileNumber relNumber,
|
||||
{
|
||||
/* Shared system relations live in {datadir}/global */
|
||||
Assert(dbOid == 0);
|
||||
Assert(backendId == InvalidBackendId);
|
||||
Assert(procNumber == INVALID_PROC_NUMBER);
|
||||
if (forkNumber != MAIN_FORKNUM)
|
||||
path = psprintf("global/%u_%s",
|
||||
relNumber, forkNames[forkNumber]);
|
||||
@@ -157,7 +157,7 @@ GetRelationPath(Oid dbOid, Oid spcOid, RelFileNumber relNumber,
|
||||
else if (spcOid == DEFAULTTABLESPACE_OID)
|
||||
{
|
||||
/* The default tablespace is {datadir}/base */
|
||||
if (backendId == InvalidBackendId)
|
||||
if (procNumber == INVALID_PROC_NUMBER)
|
||||
{
|
||||
if (forkNumber != MAIN_FORKNUM)
|
||||
path = psprintf("base/%u/%u_%s",
|
||||
@@ -171,17 +171,17 @@ GetRelationPath(Oid dbOid, Oid spcOid, RelFileNumber relNumber,
|
||||
{
|
||||
if (forkNumber != MAIN_FORKNUM)
|
||||
path = psprintf("base/%u/t%d_%u_%s",
|
||||
dbOid, backendId, relNumber,
|
||||
dbOid, procNumber, relNumber,
|
||||
forkNames[forkNumber]);
|
||||
else
|
||||
path = psprintf("base/%u/t%d_%u",
|
||||
dbOid, backendId, relNumber);
|
||||
dbOid, procNumber, relNumber);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* All other tablespaces are accessed via symlinks */
|
||||
if (backendId == InvalidBackendId)
|
||||
if (procNumber == INVALID_PROC_NUMBER)
|
||||
{
|
||||
if (forkNumber != MAIN_FORKNUM)
|
||||
path = psprintf("pg_tblspc/%u/%s/%u/%u_%s",
|
||||
@@ -198,12 +198,12 @@ GetRelationPath(Oid dbOid, Oid spcOid, RelFileNumber relNumber,
|
||||
if (forkNumber != MAIN_FORKNUM)
|
||||
path = psprintf("pg_tblspc/%u/%s/%u/t%d_%u_%s",
|
||||
spcOid, TABLESPACE_VERSION_DIRECTORY,
|
||||
dbOid, backendId, relNumber,
|
||||
dbOid, procNumber, relNumber,
|
||||
forkNames[forkNumber]);
|
||||
else
|
||||
path = psprintf("pg_tblspc/%u/%s/%u/t%d_%u",
|
||||
spcOid, TABLESPACE_VERSION_DIRECTORY,
|
||||
dbOid, backendId, relNumber);
|
||||
dbOid, procNumber, relNumber);
|
||||
}
|
||||
}
|
||||
return path;
|
||||
|
Reference in New Issue
Block a user