pgsql: Use malloc() in GetLockConflicts() when called InHotStandby to

Started by Simon Riggsover 16 years ago3 messagescomitters
Jump to latest
#1Simon Riggs
simon@2ndQuadrant.com

Log Message:
-----------
Use malloc() in GetLockConflicts() when called InHotStandby to avoid repeated
palloc calls. Current code assumed this was already true, so this is a bug fix.

Modified Files:
--------------
pgsql/src/backend/storage/lmgr:
lock.c (r1.191 -> r1.192)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/storage/lmgr/lock.c?r1=1.191&r2=1.192)

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Simon Riggs (#1)
Re: pgsql: Use malloc() in GetLockConflicts() when called InHotStandby to

sriggs@postgresql.org (Simon Riggs) writes:

Log Message:
-----------
Use malloc() in GetLockConflicts() when called InHotStandby to avoid repeated
palloc calls. Current code assumed this was already true, so this is a bug fix.

It seems pretty ugly to allocate the same pointer sometimes with malloc
and sometimes with palloc. How about palloc'ing it in TopMemoryContext
when you want it to be persistent?

regards, tom lane

#3Simon Riggs
simon@2ndQuadrant.com
In reply to: Tom Lane (#2)
Re: pgsql: Use malloc() in GetLockConflicts() when called InHotStandby to

On Thu, 2010-01-28 at 10:43 -0500, Tom Lane wrote:

sriggs@postgresql.org (Simon Riggs) writes:

Log Message:
-----------
Use malloc() in GetLockConflicts() when called InHotStandby to avoid repeated
palloc calls. Current code assumed this was already true, so this is a bug fix.

It seems pretty ugly to allocate the same pointer sometimes with malloc
and sometimes with palloc. How about palloc'ing it in TopMemoryContext
when you want it to be persistent?

Yes, that sounds more graceful. Will do.

--
Simon Riggs www.2ndQuadrant.com