mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Initial MVCC code.
New code for locking buffer' context.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.16 1998/09/01 03:25:10 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.17 1998/12/15 12:46:24 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include "storage/ipc.h"
|
||||
#include "storage/multilev.h"
|
||||
#include "storage/sinval.h"
|
||||
#include "storage/bufmgr.h"
|
||||
#include "storage/proc.h"
|
||||
@@ -92,7 +91,7 @@ CreateSharedMemoryAndSemaphores(IPCKey key)
|
||||
* ----------------
|
||||
*/
|
||||
InitLocks();
|
||||
if (InitMultiLevelLocks() == INVALID_TABLEID)
|
||||
if (InitLockTable() == INVALID_TABLEID)
|
||||
elog(FATAL, "Couldn't create the lock table");
|
||||
|
||||
/* ----------------
|
||||
@@ -145,7 +144,7 @@ AttachSharedMemoryAndSemaphores(IPCKey key)
|
||||
* ----------------
|
||||
*/
|
||||
InitLocks();
|
||||
if (InitMultiLevelLocks() == INVALID_TABLEID)
|
||||
if (InitLockTable() == INVALID_TABLEID)
|
||||
elog(FATAL, "Couldn't attach to the lock table");
|
||||
|
||||
AttachSharedInvalidationState(key);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.31 1998/09/01 04:31:49 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.32 1998/12/15 12:46:24 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -68,7 +68,8 @@
|
||||
#include "utils/dynahash.h"
|
||||
#include "utils/hsearch.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "access/transam.h"
|
||||
#include "access/xact.h"
|
||||
#include "utils/tqual.h"
|
||||
|
||||
/* shared memory global variables */
|
||||
|
||||
@@ -629,7 +630,6 @@ TransactionIdIsInProgress(TransactionId xid)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef LowLevelLocking
|
||||
/*
|
||||
* GetSnapshotData -- returns information about running transactions.
|
||||
*
|
||||
@@ -645,16 +645,15 @@ Snapshot
|
||||
GetSnapshotData(bool serialized)
|
||||
{
|
||||
Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData));
|
||||
TransactionId snapshot->xip = (TransactionId *)
|
||||
malloc(32 * sizeof(TransactionId));
|
||||
ShmemIndexEnt *result;
|
||||
PROC *proc;
|
||||
TransactionId cid = GetCurrentTransactionId();
|
||||
uint count = 0;
|
||||
unit free = 31;
|
||||
uint32 count = 0;
|
||||
uint32 have = 31;
|
||||
|
||||
Assert(ShmemIndex);
|
||||
|
||||
snapshot->xip = (TransactionId *) malloc(32 * sizeof(TransactionId));
|
||||
snapshot->xmax = cid;
|
||||
snapshot->xmin = cid;
|
||||
|
||||
@@ -676,20 +675,20 @@ GetSnapshotData(bool serialized)
|
||||
continue;
|
||||
proc = (PROC *) MAKE_PTR(result->location);
|
||||
if (proc == MyProc || proc->xid < FirstTransactionId ||
|
||||
serialized && proc->xid >= cid)
|
||||
(serialized && proc->xid >= cid))
|
||||
continue;
|
||||
if (proc->xid < snapshot->xmin)
|
||||
snapshot->xmin = proc->xid;
|
||||
else if (proc->xid > snapshot->xmax)
|
||||
snapshot->xmax = proc->xid;
|
||||
if (free == 0)
|
||||
if (have == 0)
|
||||
{
|
||||
snapshot->xip = (TransactionId *) realloc(snapshot->xip,
|
||||
(count + 33) * sizeof(TransactionId));
|
||||
free = 32;
|
||||
have = 32;
|
||||
}
|
||||
snapshot->xip[count] = proc->xid;
|
||||
free--;
|
||||
have--;
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -699,5 +698,3 @@ GetSnapshotData(bool serialized)
|
||||
elog(ERROR, "GetSnapshotData: ShmemIndex corrupted");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user