*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.185 2005/03/27 23:52:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.186 2005/03/28 01:50:32 tgl Exp $
*
*
* INTERFACE ROUTINES
#include "pgstat.h"
-/* comments are in heap_update */
-static xl_heaptid _locked_tuple_;
-static void _heap_unlock_tuple(void *data);
static XLogRecPtr log_heap_update(Relation reln, Buffer oldbuf,
ItemPointerData from, Buffer newbuf, HeapTuple newtup, bool move);
* context lock (but not the pin!) on the old tuple's buffer while we
* are off doing TOAST and/or table-file-extension work. We must mark
* the old tuple to show that it's already being updated, else other
- * processes may try to update it themselves. To avoid second XLOG log
- * record, we use xact mgr hook to unlock old tuple without reading
- * log if xact will abort before update is logged. In the event of
- * crash prio logging, TQUAL routines will see HEAP_XMAX_UNLOGGED
- * flag...
- *
- * NOTE: this trick is useless currently but saved for future when we'll
- * implement UNDO and will re-use transaction IDs after postmaster
- * startup.
+ * processes may try to update it themselves.
*
* We need to invoke the toaster if there are already any out-of-line
* toasted values present, or if the new tuple is over-threshold.
if (need_toast || newtupsize > pagefree)
{
- _locked_tuple_.node = relation->rd_node;
- _locked_tuple_.tid = oldtup.t_self;
- XactPushRollback(_heap_unlock_tuple, (void *) &_locked_tuple_);
-
oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
HEAP_XMAX_INVALID |
HEAP_MARKED_FOR_UPDATE |
HEAP_MOVED);
- oldtup.t_data->t_infomask |= HEAP_XMAX_UNLOGGED;
HeapTupleHeaderSetXmax(oldtup.t_data, xid);
HeapTupleHeaderSetCmax(oldtup.t_data, cid);
already_marked = true;
RelationPutHeapTuple(relation, newbuf, newtup); /* insert new tuple */
- if (already_marked)
- {
- oldtup.t_data->t_infomask &= ~HEAP_XMAX_UNLOGGED;
- XactPopRollback();
- }
- else
+ if (!already_marked)
{
oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
HEAP_XMAX_INVALID |
}
-static void
-_heap_unlock_tuple(void *data)
-{
- TransactionId xid = GetCurrentTransactionId();
- xl_heaptid *xltid = (xl_heaptid *) data;
- Relation reln = XLogOpenRelation(false, RM_HEAP_ID, xltid->node);
- Buffer buffer;
- Page page;
- OffsetNumber offnum;
- ItemId lp;
- HeapTupleHeader htup;
-
- if (!RelationIsValid(reln))
- elog(PANIC, "_heap_unlock_tuple: can't open relation");
-
- buffer = XLogReadBuffer(false, reln,
- ItemPointerGetBlockNumber(&(xltid->tid)));
- if (!BufferIsValid(buffer))
- elog(PANIC, "_heap_unlock_tuple: can't read buffer");
-
- page = (Page) BufferGetPage(buffer);
- if (PageIsNew((PageHeader) page))
- elog(PANIC, "_heap_unlock_tuple: uninitialized page");
-
- offnum = ItemPointerGetOffsetNumber(&(xltid->tid));
- if (offnum > PageGetMaxOffsetNumber(page))
- elog(PANIC, "_heap_unlock_tuple: invalid itemid");
- lp = PageGetItemId(page, offnum);
-
- if (!ItemIdIsUsed(lp) || ItemIdDeleted(lp))
- elog(PANIC, "_heap_unlock_tuple: unused/deleted tuple in rollback");
-
- htup = (HeapTupleHeader) PageGetItem(page, lp);
-
- if (!TransactionIdEquals(HeapTupleHeaderGetXmax(htup), xid))
- elog(PANIC, "_heap_unlock_tuple: invalid xmax in rollback");
- htup->t_infomask &= ~HEAP_XMAX_UNLOGGED;
- htup->t_infomask |= HEAP_XMAX_INVALID;
- LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
- WriteBuffer(buffer);
-}
-
void
heap_redo(XLogRecPtr lsn, XLogRecord *record)
{
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.72 2004/12/31 22:03:21 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.73 2005/03/28 01:50:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* attribute(s) */
#define HEAP_HASEXTENDED 0x000C /* the two above combined */
#define HEAP_HASOID 0x0010 /* has an object-id field */
-/* 0x0020 and 0x0040 are unused */
-#define HEAP_XMAX_UNLOGGED 0x0080 /* to lock tuple for update
- * without logging */
+/* 0x0020, 0x0040 and 0x0080 are unused */
#define HEAP_XMIN_COMMITTED 0x0100 /* t_xmin committed */
#define HEAP_XMIN_INVALID 0x0200 /* t_xmin invalid/aborted */
#define HEAP_XMAX_COMMITTED 0x0400 /* t_xmax committed */
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.74 2004/12/31 22:03:21 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.75 2005/03/28 01:50:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern int xactGetCommittedChildren(TransactionId **ptr);
-extern void XactPushRollback(void (*func) (void *), void *data);
-extern void XactPopRollback(void);
-
extern void xact_redo(XLogRecPtr lsn, XLogRecord *record);
extern void xact_undo(XLogRecPtr lsn, XLogRecord *record);
extern void xact_desc(char *buf, uint8 xl_info, char *rec);