1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-27 07:42:10 +03:00

Serialized mode works!

This commit is contained in:
Vadim B. Mikheev
1998-12-16 11:53:55 +00:00
parent 54c3e65242
commit c13a64d7fb
9 changed files with 209 additions and 47 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.32 1998/12/15 12:46:24 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.33 1998/12/16 11:53:46 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -633,27 +633,21 @@ TransactionIdIsInProgress(TransactionId xid)
/*
* GetSnapshotData -- returns information about running transactions.
*
* InvalidTransactionId is used as terminator in snapshot->xip array.
* If serialized is true then XID >= current xact ID will not be
* placed in array. Current xact ID are never placed there (just
* to reduce its length, xmin/xmax may be equal to cid).
* MyProc->xmin will be setted if equal to InvalidTransactionId.
*
* Yet another strange func for this place... - vadim 07/21/98
*/
Snapshot
GetSnapshotData(bool serialized)
GetSnapshotData(void)
{
Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData));
ShmemIndexEnt *result;
PROC *proc;
TransactionId cid = GetCurrentTransactionId();
uint32 count = 0;
uint32 have = 31;
uint32 have = 32;
Assert(ShmemIndex);
snapshot->xip = (TransactionId *) malloc(32 * sizeof(TransactionId));
snapshot->xip = (TransactionId *) malloc(have * sizeof(TransactionId));
snapshot->xmax = cid;
snapshot->xmin = cid;
@@ -667,15 +661,14 @@ GetSnapshotData(bool serialized)
if (MyProc->xmin == InvalidTransactionId)
MyProc->xmin = snapshot->xmin;
SpinRelease(ShmemIndexLock);
snapshot->xip[count] = InvalidTransactionId;
snapshot->xcnt = count;
return snapshot;
}
if (result->location == INVALID_OFFSET ||
strncmp(result->key, "PID ", 4) != 0)
continue;
proc = (PROC *) MAKE_PTR(result->location);
if (proc == MyProc || proc->xid < FirstTransactionId ||
(serialized && proc->xid >= cid))
if (proc == MyProc || proc->xid < FirstTransactionId)
continue;
if (proc->xid < snapshot->xmin)
snapshot->xmin = proc->xid;
@@ -684,7 +677,7 @@ GetSnapshotData(bool serialized)
if (have == 0)
{
snapshot->xip = (TransactionId *) realloc(snapshot->xip,
(count + 33) * sizeof(TransactionId));
(count + 32) * sizeof(TransactionId));
have = 32;
}
snapshot->xip[count] = proc->xid;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.20 1998/12/15 12:46:30 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.21 1998/12/16 11:53:48 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -325,6 +325,7 @@ XactLockTableWait(TransactionId xid)
LockAcquire(LockTableId, &tag, ShareLock);
TransactionIdFlushCache();
/*
* Transaction was committed/aborted/crashed -
* we have to update pg_log if transaction is still