88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.120 2001/06/27 23:31:38 tgl Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.121 2001/06/29 21:08:23 tgl Exp $
1212 *
1313 *
1414 * INTERFACE ROUTINES
@@ -202,8 +202,7 @@ heapgettup(Relation relation,
202202
203203* buffer = ReleaseAndReadBuffer (* buffer ,
204204relation ,
205- ItemPointerGetBlockNumber (tid ),
206- false);
205+ ItemPointerGetBlockNumber (tid ));
207206if (!BufferIsValid (* buffer ))
208207elog (ERROR ,"heapgettup: failed ReadBuffer" );
209208
@@ -238,8 +237,7 @@ heapgettup(Relation relation,
238237
239238* buffer = ReleaseAndReadBuffer (* buffer ,
240239relation ,
241- page ,
242- false);
240+ page );
243241if (!BufferIsValid (* buffer ))
244242elog (ERROR ,"heapgettup: failed ReadBuffer" );
245243
@@ -280,8 +278,7 @@ heapgettup(Relation relation,
280278
281279* buffer = ReleaseAndReadBuffer (* buffer ,
282280relation ,
283- page ,
284- false);
281+ page );
285282if (!BufferIsValid (* buffer ))
286283elog (ERROR ,"heapgettup: failed ReadBuffer" );
287284
@@ -374,8 +371,7 @@ heapgettup(Relation relation,
374371
375372* buffer = ReleaseAndReadBuffer (* buffer ,
376373relation ,
377- page ,
378- false);
374+ page );
379375if (!BufferIsValid (* buffer ))
380376elog (ERROR ,"heapgettup: failed ReadBuffer" );
381377
@@ -1088,8 +1084,8 @@ heap_insert(Relation relation, HeapTuple tup)
10881084heap_tuple_toast_attrs (relation ,tup ,NULL );
10891085#endif
10901086
1091- /* Find bufferfor this tuple */
1092- buffer = RelationGetBufferForTuple (relation ,tup -> t_len ,0 );
1087+ /* Find bufferto insert this tuple into */
1088+ buffer = RelationGetBufferForTuple (relation ,tup -> t_len ,InvalidBuffer );
10931089
10941090/* NO ELOG(ERROR) from here till changes are logged */
10951091START_CRIT_SECTION ();
@@ -1501,18 +1497,16 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
15011497 * buffer locks on both old and new pages. To avoid deadlock against
15021498 * some other backend trying to get the same two locks in the other
15031499 * order, we must be consistent about the order we get the locks in.
1504- * We use the rule "lock thehigher -numbered page of the relation
1500+ * We use the rule "lock thelower -numbered page of the relation
15051501 * first". To implement this, we must do RelationGetBufferForTuple
1506- * while not holding the lock on the old page, and we musttell it
1507- * togive us a page beyond theold page .
1502+ * while not holding the lock on the old page, and we mustrely on it
1503+ * toget the locks on both pages in thecorrect order .
15081504 */
15091505if (newtupsize > pagefree )
15101506{
15111507/* Assume there's no chance to put newtup on same page. */
15121508newbuf = RelationGetBufferForTuple (relation ,newtup -> t_len ,
1513- BufferGetBlockNumber (buffer )+ 1 );
1514- /* Now reacquire lock on old tuple's page. */
1515- LockBuffer (buffer ,BUFFER_LOCK_EXCLUSIVE );
1509+ buffer );
15161510}
15171511else
15181512{
@@ -1529,8 +1523,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
15291523 */
15301524LockBuffer (buffer ,BUFFER_LOCK_UNLOCK );
15311525newbuf = RelationGetBufferForTuple (relation ,newtup -> t_len ,
1532- BufferGetBlockNumber (buffer )+ 1 );
1533- LockBuffer (buffer ,BUFFER_LOCK_EXCLUSIVE );
1526+ buffer );
15341527}
15351528else
15361529{
@@ -1550,7 +1543,8 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
15501543
15511544/*
15521545 * At this point newbuf and buffer are both pinned and locked,
1553- * and newbuf has enough space for the new tuple.
1546+ * and newbuf has enough space for the new tuple. If they are
1547+ * the same buffer, only one pin is held.
15541548 */
15551549
15561550/* NO ELOG(ERROR) from here till changes are logged */