Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3643248

Browse files
committed
TransactionIdIsInProgress is here now and gives quality answer
by scanning PROC structures of all running backend.
1 parent47312ec commit3643248

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

‎src/backend/storage/ipc/shmem.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.6 1996/11/10 03:02:27 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.7 1996/11/27 07:20:07 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -64,6 +64,7 @@
6464
#include"storage/ipc.h"
6565
#include"storage/shmem.h"
6666
#include"storage/spin.h"
67+
#include"storage/proc.h"
6768
#include"utils/dynahash.h"
6869
#include"utils/hsearch.h"
6970

@@ -559,4 +560,43 @@ ShmemInitStruct(char *name, unsigned long size, bool *foundPtr)
559560
}
560561

561562

563+
/*
564+
* TransactionIdIsInProgress -- is given transaction running by some backend
565+
*
566+
* Strange place for this func, but we have to lookup process data structures
567+
* for all running backends. - vadim 11/26/96
568+
*/
569+
bool
570+
TransactionIdIsInProgress (TransactionIdxid)
571+
{
572+
BindingEnt*result;
573+
PROC*proc;
574+
575+
Assert (BindingTable);
576+
577+
SpinAcquire(BindingLock);
578+
579+
(void)hash_seq ((HTAB*)NULL);
580+
while ( (result= (BindingEnt*)hash_seq (BindingTable))!=NULL )
581+
{
582+
if (result== (BindingEnt*) TRUE )
583+
{
584+
SpinRelease(BindingLock);
585+
return (false);
586+
}
587+
if (result->location==INVALID_OFFSET||
588+
strncmp (result->key,"PID ",4)!=0 )
589+
continue;
590+
proc= (PROC*)MAKE_PTR (result->location);
591+
if (proc->xid==xid )
592+
{
593+
SpinRelease(BindingLock);
594+
return (true);
595+
}
596+
}
597+
598+
SpinRelease(BindingLock);
599+
elog (WARN,"TransactionIdIsInProgress: BindingTable corrupted");
600+
return (false);
601+
}
562602

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp