On Wed, 2008-11-12 at 16:25 -0500, Tom Lane wrote:
> The alternative I was thinking about involved taking an exclusive buffer
> lock on the page containing the tuple to be updated in-place. The point
> being that you have to examine the old tuple contents and decide whether
> to update after you have lock, not before. I think this would amount to
> refactoring heap_inplace_update into two operations: fetch/lock and
> update/unlock. (I guess there should be a third function to release
> without updating, too --- that would really just be an unlock-buffer
> operation, but it'd be better if callers didn't explicitly know that.)
> The callers would probably still use the syscache to obtain the tuple
> address, but they wouldn't rely on it to supply the tuple image.
Here's what I'm working on:
HeapTuple
heap_inplace_xxx(Relation relation, HeapTuple tuple, Buffer *buffer)
xxx = (fetch, update, release)
usage:
tuple = heap_inplace_fetch(rel, tuple, &buffer);
....
if (dirty)heap_inplace_fe(rel, tuple, &buffer);
elseheap_inplace_fetch(rel, tuple, &buffer);
heap_inplace_fetch takes as input "tuple" which is a palloc'd tuple,
extracts from it the tid of the tuple, reads the buffer, locks it, then
releases the original tuple. It then returns a copy of the on-block
tuple. So all other code the same as before when we were working on a
copy produced from the syscache.
Is that roughly what you intended?
-- Simon Riggs www.2ndQuadrant.comPostgreSQL Training, Services and Support