88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.185 2005/03/27 23:52:58 tgl Exp $
11+ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.186 2005/03/28 01:50:32 tgl Exp $
1212 *
1313 *
1414 * INTERFACE ROUTINES
5353#include "pgstat.h"
5454
5555
56- /* comments are in heap_update */
57- static xl_heaptid _locked_tuple_ ;
58- static void _heap_unlock_tuple (void * data );
5956static XLogRecPtr log_heap_update (Relation reln , Buffer oldbuf ,
6057 ItemPointerData from , Buffer newbuf , HeapTuple newtup , bool move );
6158
@@ -1620,15 +1617,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
16201617 * context lock (but not the pin!) on the old tuple's buffer while we
16211618 * are off doing TOAST and/or table-file-extension work. We must mark
16221619 * the old tuple to show that it's already being updated, else other
1623- * processes may try to update it themselves. To avoid second XLOG log
1624- * record, we use xact mgr hook to unlock old tuple without reading
1625- * log if xact will abort before update is logged. In the event of
1626- * crash prio logging, TQUAL routines will see HEAP_XMAX_UNLOGGED
1627- * flag...
1628- *
1629- * NOTE: this trick is useless currently but saved for future when we'll
1630- * implement UNDO and will re-use transaction IDs after postmaster
1631- * startup.
1620+ * processes may try to update it themselves.
16321621 *
16331622 * We need to invoke the toaster if there are already any out-of-line
16341623 * toasted values present, or if the new tuple is over-threshold.
@@ -1642,15 +1631,10 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
16421631
16431632 if (need_toast || newtupsize > pagefree )
16441633 {
1645- _locked_tuple_ .node = relation -> rd_node ;
1646- _locked_tuple_ .tid = oldtup .t_self ;
1647- XactPushRollback (_heap_unlock_tuple , (void * ) & _locked_tuple_ );
1648-
16491634 oldtup .t_data -> t_infomask &= ~(HEAP_XMAX_COMMITTED |
16501635 HEAP_XMAX_INVALID |
16511636 HEAP_MARKED_FOR_UPDATE |
16521637 HEAP_MOVED );
1653- oldtup .t_data -> t_infomask |= HEAP_XMAX_UNLOGGED ;
16541638 HeapTupleHeaderSetXmax (oldtup .t_data , xid );
16551639 HeapTupleHeaderSetCmax (oldtup .t_data , cid );
16561640 already_marked = true;
@@ -1731,12 +1715,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
17311715
17321716 RelationPutHeapTuple (relation , newbuf , newtup ); /* insert new tuple */
17331717
1734- if (already_marked )
1735- {
1736- oldtup .t_data -> t_infomask &= ~HEAP_XMAX_UNLOGGED ;
1737- XactPopRollback ();
1738- }
1739- else
1718+ if (!already_marked )
17401719 {
17411720 oldtup .t_data -> t_infomask &= ~(HEAP_XMAX_COMMITTED |
17421721 HEAP_XMAX_INVALID |
@@ -2585,48 +2564,6 @@ newsame:;
25852564
25862565}
25872566
2588- static void
2589- _heap_unlock_tuple (void * data )
2590- {
2591- TransactionId xid = GetCurrentTransactionId ();
2592- xl_heaptid * xltid = (xl_heaptid * ) data ;
2593- Relation reln = XLogOpenRelation (false, RM_HEAP_ID , xltid -> node );
2594- Buffer buffer ;
2595- Page page ;
2596- OffsetNumber offnum ;
2597- ItemId lp ;
2598- HeapTupleHeader htup ;
2599-
2600- if (!RelationIsValid (reln ))
2601- elog (PANIC , "_heap_unlock_tuple: can't open relation" );
2602-
2603- buffer = XLogReadBuffer (false, reln ,
2604- ItemPointerGetBlockNumber (& (xltid -> tid )));
2605- if (!BufferIsValid (buffer ))
2606- elog (PANIC , "_heap_unlock_tuple: can't read buffer" );
2607-
2608- page = (Page ) BufferGetPage (buffer );
2609- if (PageIsNew ((PageHeader ) page ))
2610- elog (PANIC , "_heap_unlock_tuple: uninitialized page" );
2611-
2612- offnum = ItemPointerGetOffsetNumber (& (xltid -> tid ));
2613- if (offnum > PageGetMaxOffsetNumber (page ))
2614- elog (PANIC , "_heap_unlock_tuple: invalid itemid" );
2615- lp = PageGetItemId (page , offnum );
2616-
2617- if (!ItemIdIsUsed (lp ) || ItemIdDeleted (lp ))
2618- elog (PANIC , "_heap_unlock_tuple: unused/deleted tuple in rollback" );
2619-
2620- htup = (HeapTupleHeader ) PageGetItem (page , lp );
2621-
2622- if (!TransactionIdEquals (HeapTupleHeaderGetXmax (htup ), xid ))
2623- elog (PANIC , "_heap_unlock_tuple: invalid xmax in rollback" );
2624- htup -> t_infomask &= ~HEAP_XMAX_UNLOGGED ;
2625- htup -> t_infomask |= HEAP_XMAX_INVALID ;
2626- LockBuffer (buffer , BUFFER_LOCK_UNLOCK );
2627- WriteBuffer (buffer );
2628- }
2629-
26302567void
26312568heap_redo (XLogRecPtr lsn , XLogRecord * record )
26322569{
0 commit comments