Commit ddd96e1f authored by Tom Lane's avatar Tom Lane

Guard against malloc failure. Also, don't examine segP->lastBackend

until we hold the spinlock.
parent d8adce89
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.31 2001/05/18 21:24:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.32 2001/06/01 20:07:16 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -283,15 +283,24 @@ GetSnapshotData(bool serializable) ...@@ -283,15 +283,24 @@ GetSnapshotData(bool serializable)
int index; int index;
int count = 0; int count = 0;
if (snapshot == NULL)
elog(ERROR, "Memory exhausted in GetSnapshotData");
snapshot->xmin = GetCurrentTransactionId();
SpinAcquire(SInvalLock);
/* /*
* There can be no more than lastBackend active transactions, so this * There can be no more than lastBackend active transactions, so this
* is enough space: * is enough space:
*/ */
snapshot->xip = (TransactionId *) snapshot->xip = (TransactionId *)
malloc(segP->lastBackend * sizeof(TransactionId)); malloc(segP->lastBackend * sizeof(TransactionId));
snapshot->xmin = GetCurrentTransactionId(); if (snapshot->xip == NULL)
{
SpinAcquire(SInvalLock); SpinRelease(SInvalLock);
elog(ERROR, "Memory exhausted in GetSnapshotData");
}
/* /*
* Unfortunately, we have to call ReadNewTransactionId() after * Unfortunately, we have to call ReadNewTransactionId() after
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment