8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.192 2010/01/28 10:05:37 sriggs Exp $
11
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.193 2010/01/29 19:45:12 sriggs Exp $
12
12
*
13
13
* NOTES
14
14
* A lock table is a shared memory hash table. When
@@ -1790,7 +1790,7 @@ LockReassignCurrentOwner(void)
1790
1790
VirtualTransactionId *
1791
1791
GetLockConflicts (const LOCKTAG * locktag , LOCKMODE lockmode )
1792
1792
{
1793
- static VirtualTransactionId * vxids = NULL ;
1793
+ static VirtualTransactionId * vxids ;
1794
1794
LOCKMETHODID lockmethodid = locktag -> locktag_lockmethodid ;
1795
1795
LockMethod lockMethodTable ;
1796
1796
LOCK * lock ;
@@ -1810,24 +1810,18 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode)
1810
1810
/*
1811
1811
* Allocate memory to store results, and fill with InvalidVXID. We only
1812
1812
* need enough space for MaxBackends + a terminator, since prepared xacts
1813
- * don't count.
1813
+ * don't count. InHotStandby allocate once in TopMemoryContext.
1814
1814
*/
1815
- if (!InHotStandby )
1816
- vxids = (VirtualTransactionId * )
1817
- palloc0 (sizeof (VirtualTransactionId ) * (MaxBackends + 1 ));
1818
- else
1815
+ if (InHotStandby )
1819
1816
{
1820
1817
if (vxids == NULL )
1821
- {
1822
1818
vxids = (VirtualTransactionId * )
1823
- malloc (sizeof (VirtualTransactionId ) * (MaxBackends + 1 ));
1824
- if (vxids == NULL )
1825
- ereport (ERROR ,
1826
- (errcode (ERRCODE_OUT_OF_MEMORY ),
1827
- errmsg ("out of memory" )));
1828
-
1829
- }
1819
+ MemoryContextAlloc (TopMemoryContext ,
1820
+ sizeof (VirtualTransactionId ) * (MaxBackends + 1 ));
1830
1821
}
1822
+ else
1823
+ vxids = (VirtualTransactionId * )
1824
+ palloc0 (sizeof (VirtualTransactionId ) * (MaxBackends + 1 ));
1831
1825
1832
1826
/*
1833
1827
* Look up the lock object matching the tag.
0 commit comments