diff options
author | Vadim B. Mikheev <vadim4o@yahoo.com> | 1996-11-27 07:20:07 +0000 |
---|---|---|
committer | Vadim B. Mikheev <vadim4o@yahoo.com> | 1996-11-27 07:20:07 +0000 |
commit | 3643248ae2d8c2030616f7de15d6eff6136e3a03 (patch) | |
tree | c2b5477a1582e6e6460996e7b5d773e1aa81af06 /src | |
parent | 47312ec134558e662579cea3eca1b0ac8f401fe6 (diff) | |
download | postgresql-3643248ae2d8c2030616f7de15d6eff6136e3a03.tar.gz postgresql-3643248ae2d8c2030616f7de15d6eff6136e3a03.zip |
TransactionIdIsInProgress is here now and gives quality answer
by scanning PROC structures of all running backend.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/storage/ipc/shmem.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index 4a3ad33e9b6..4badedd32fe 100644 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.6 1996/11/10 03:02:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.7 1996/11/27 07:20:07 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -64,6 +64,7 @@ #include "storage/ipc.h" #include "storage/shmem.h" #include "storage/spin.h" +#include "storage/proc.h" #include "utils/dynahash.h" #include "utils/hsearch.h" @@ -559,4 +560,43 @@ ShmemInitStruct(char *name, unsigned long size, bool *foundPtr) } +/* + * TransactionIdIsInProgress -- is given transaction running by some backend + * + * Strange place for this func, but we have to lookup process data structures + * for all running backends. - vadim 11/26/96 + */ +bool +TransactionIdIsInProgress (TransactionId xid) +{ + BindingEnt *result; + PROC *proc; + + Assert (BindingTable); + + SpinAcquire(BindingLock); + + (void) hash_seq ((HTAB *)NULL); + while ( (result = (BindingEnt *) hash_seq (BindingTable)) != NULL ) + { + if ( result == (BindingEnt *) TRUE ) + { + SpinRelease(BindingLock); + return (false); + } + if ( result->location == INVALID_OFFSET || + strncmp (result->key, "PID ", 4) != 0 ) + continue; + proc = (PROC *) MAKE_PTR (result->location); + if ( proc->xid == xid ) + { + SpinRelease(BindingLock); + return (true); + } + } + + SpinRelease(BindingLock); + elog (WARN,"TransactionIdIsInProgress: BindingTable corrupted"); + return (false); +} |