int32 *pids;
BackendId *ids;
int count;
+ int max_backends = GetMaxBackends();
/*
* Identify backends that we need to signal. We don't want to send
* XXX in principle these pallocs could fail, which would be bad. Maybe
* preallocate the arrays? They're not that large, though.
*/
- pids = (int32 *) palloc(GetMaxBackends() * sizeof(int32));
- ids = (BackendId *) palloc(GetMaxBackends() * sizeof(BackendId));
+ pids = (int32 *) palloc(max_backends * sizeof(int32));
+ ids = (BackendId *) palloc(max_backends * sizeof(BackendId));
count = 0;
LWLockAcquire(NotifyQueueLock, LW_EXCLUSIVE);
LWLock *partitionLock;
int count = 0;
int fast_count = 0;
+ int max_backends = GetMaxBackends();
if (lockmethodid <= 0 || lockmethodid >= lengthof(LockMethods))
elog(ERROR, "unrecognized lock method: %d", lockmethodid);
vxids = (VirtualTransactionId *)
MemoryContextAlloc(TopMemoryContext,
sizeof(VirtualTransactionId) *
- (GetMaxBackends() + max_prepared_xacts + 1));
+ (max_backends + max_prepared_xacts + 1));
}
else
vxids = (VirtualTransactionId *)
palloc0(sizeof(VirtualTransactionId) *
- (GetMaxBackends() + max_prepared_xacts + 1));
+ (max_backends + max_prepared_xacts + 1));
/* Compute hash code and partition lock, and look up conflicting modes. */
hashcode = LockTagHashCode(locktag);
LWLockRelease(partitionLock);
- if (count > GetMaxBackends() + max_prepared_xacts) /* should never happen */
+ if (count > max_backends + max_prepared_xacts) /* should never happen */
elog(PANIC, "too many conflicting locks found");
vxids[count].backendId = InvalidBackendId;
int *blockers;
int num_blockers;
Datum *blocker_datums;
+ int max_backends = GetMaxBackends();
/* A buffer big enough for any possible blocker list without truncation */
- blockers = (int *) palloc(GetMaxBackends() * sizeof(int));
+ blockers = (int *) palloc(max_backends * sizeof(int));
/* Collect a snapshot of processes waited for by GetSafeSnapshot */
num_blockers =
- GetSafeSnapshotBlockingPids(blocked_pid, blockers, GetMaxBackends());
+ GetSafeSnapshotBlockingPids(blocked_pid, blockers, max_backends);
/* Convert int array to Datum array */
if (num_blockers > 0)