8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*
14
14
* INTERFACE ROUTINES
53
53
#include "pgstat.h"
54
54
55
55
56
- /* comments are in heap_update */
57
- static xl_heaptid _locked_tuple_ ;
58
- static void _heap_unlock_tuple (void * data );
59
56
static XLogRecPtr log_heap_update (Relation reln , Buffer oldbuf ,
60
57
ItemPointerData from , Buffer newbuf , HeapTuple newtup , bool move );
61
58
@@ -1620,15 +1617,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
1620
1617
* context lock (but not the pin!) on the old tuple's buffer while we
1621
1618
* are off doing TOAST and/or table-file-extension work. We must mark
1622
1619
* 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.
1632
1621
*
1633
1622
* We need to invoke the toaster if there are already any out-of-line
1634
1623
* toasted values present, or if the new tuple is over-threshold.
@@ -1642,15 +1631,10 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
1642
1631
1643
1632
if (need_toast || newtupsize > pagefree )
1644
1633
{
1645
- _locked_tuple_ .node = relation -> rd_node ;
1646
- _locked_tuple_ .tid = oldtup .t_self ;
1647
- XactPushRollback (_heap_unlock_tuple , (void * ) & _locked_tuple_ );
1648
-
1649
1634
oldtup .t_data -> t_infomask &= ~(HEAP_XMAX_COMMITTED |
1650
1635
HEAP_XMAX_INVALID |
1651
1636
HEAP_MARKED_FOR_UPDATE |
1652
1637
HEAP_MOVED );
1653
- oldtup .t_data -> t_infomask |= HEAP_XMAX_UNLOGGED ;
1654
1638
HeapTupleHeaderSetXmax (oldtup .t_data , xid );
1655
1639
HeapTupleHeaderSetCmax (oldtup .t_data , cid );
1656
1640
already_marked = true;
@@ -1731,12 +1715,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
1731
1715
1732
1716
RelationPutHeapTuple (relation , newbuf , newtup ); /* insert new tuple */
1733
1717
1734
- if (already_marked )
1735
- {
1736
- oldtup .t_data -> t_infomask &= ~HEAP_XMAX_UNLOGGED ;
1737
- XactPopRollback ();
1738
- }
1739
- else
1718
+ if (!already_marked )
1740
1719
{
1741
1720
oldtup .t_data -> t_infomask &= ~(HEAP_XMAX_COMMITTED |
1742
1721
HEAP_XMAX_INVALID |
@@ -2585,48 +2564,6 @@ newsame:;
2585
2564
2586
2565
}
2587
2566
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
-
2630
2567
void
2631
2568
heap_redo (XLogRecPtr lsn , XLogRecord * record )
2632
2569
{
0 commit comments