Index: src/backend/access/heap/heapam.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/access/heap/heapam.c,v retrieving revision 1.225 diff -c -r1.225 heapam.c *** src/backend/access/heap/heapam.c 25 Jan 2007 02:17:25 -0000 1.225 --- src/backend/access/heap/heapam.c 27 Jan 2007 03:51:23 -0000 *************** *** 1248,1253 **** --- 1248,1254 ---- BlockNumber blk; ItemPointerData ctid; TransactionId priorXmax; + Buffer buffer = InvalidBuffer; /* this is to avoid Assert failures on bad input */ if (!ItemPointerIsValid(tid)) *************** *** 1277,1283 **** priorXmax = InvalidTransactionId; /* cannot check first XMIN */ for (;;) { - Buffer buffer; PageHeader dp; OffsetNumber offnum; ItemId lp; --- 1278,1283 ---- *************** *** 1287,1293 **** /* * Read, pin, and lock the page. */ ! buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(&ctid)); LockBuffer(buffer, BUFFER_LOCK_SHARE); dp = (PageHeader) BufferGetPage(buffer); --- 1287,1294 ---- /* * Read, pin, and lock the page. */ ! buffer = ReleaseAndReadBuffer(buffer, relation, ! ItemPointerGetBlockNumber(&ctid)); LockBuffer(buffer, BUFFER_LOCK_SHARE); dp = (PageHeader) BufferGetPage(buffer); *************** *** 1345,1351 **** ctid = tp.t_data->t_ctid; priorXmax = HeapTupleHeaderGetXmax(tp.t_data); ! UnlockReleaseBuffer(buffer); } /* end of loop */ } --- 1346,1352 ---- ctid = tp.t_data->t_ctid; priorXmax = HeapTupleHeaderGetXmax(tp.t_data); ! LockBuffer(buffer, BUFFER_LOCK_UNLOCK); } /* end of loop */ } Index: src/backend/executor/execMain.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/executor/execMain.c,v retrieving revision 1.285 diff -c -r1.285 execMain.c *** src/backend/executor/execMain.c 25 Jan 2007 04:35:10 -0000 1.285 --- src/backend/executor/execMain.c 27 Jan 2007 03:51:24 -0000 *************** *** 1895,1900 **** --- 1895,1901 ---- HeapTupleData tuple; HeapTuple copyTuple = NULL; bool endNode; + Buffer buffer = InvalidBuffer; Assert(rti != 0); *************** *** 1929,1937 **** tuple.t_self = *tid; for (;;) { ! Buffer buffer; ! ! if (heap_fetch(relation, SnapshotDirty, &tuple, &buffer, true, NULL)) { /* * If xmin isn't what we're expecting, the slot must have been --- 1930,1937 ---- tuple.t_self = *tid; for (;;) { ! if (heap_release_fetch(relation, SnapshotDirty, &tuple, &buffer, ! true, NULL)) { /* * If xmin isn't what we're expecting, the slot must have been *************** *** 1960,1965 **** --- 1960,1966 ---- { ReleaseBuffer(buffer); XactLockTableWait(SnapshotDirty->xmax); + buffer = InvalidBuffer; continue; /* loop back to repeat heap_fetch */ } *************** *** 2032,2038 **** tuple.t_self = tuple.t_data->t_ctid; /* updated row should have xmin matching this xmax */ priorXmax = HeapTupleHeaderGetXmax(tuple.t_data); - ReleaseBuffer(buffer); /* loop back to fetch next in chain */ } --- 2033,2038 ----