diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-07-06 21:04:26 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-07-06 21:04:26 +0000 |
commit | 55432fedd2b3383c0cd0724a70ad0ae5134710f3 (patch) | |
tree | d6aa387a59107c56fd2d4fdfa6c7b12320bd0d70 /src/backend/storage/ipc/sinval.c | |
parent | 1e9e5defc256708ca40009640d337baeca5698ec (diff) |
Implement LockBufferForCleanup(), which will allow concurrent VACUUM
to wait until it's safe to remove tuples and compact free space in a
shared buffer page. Miscellaneous small code cleanups in bufmgr, too.
Diffstat (limited to 'src/backend/storage/ipc/sinval.c')
-rw-r--r-- | src/backend/storage/ipc/sinval.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c index 6a3129ffd56..5794207eb18 100644 --- a/src/backend/storage/ipc/sinval.c +++ b/src/backend/storage/ipc/sinval.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.34 2001/06/19 19:42:15 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.35 2001/07/06 21:04:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,6 @@ #include <sys/types.h> -#include "storage/backendid.h" #include "storage/proc.h" #include "storage/sinval.h" #include "storage/sinvaladt.h" @@ -411,3 +410,31 @@ GetUndoRecPtr(void) return (urec); } + +/* + * BackendIdGetProc - given a BackendId, find its PROC structure + * + * This is a trivial lookup in the ProcState array. We assume that the caller + * knows that the backend isn't going to go away, so we do not bother with + * locking. + */ +struct proc * +BackendIdGetProc(BackendId procId) +{ + SISeg *segP = shmInvalBuffer; + + if (procId > 0 && procId <= segP->lastBackend) + { + ProcState *stateP = &segP->procState[procId - 1]; + SHMEM_OFFSET pOffset = stateP->procStruct; + + if (pOffset != INVALID_OFFSET) + { + PROC *proc = (PROC *) MAKE_PTR(pOffset); + + return proc; + } + } + + return NULL; +} |