This patch wraps all accesses to t_xmin, t_cmin, t_xmax, and t_cmax in
HeapTupleHeaderData in setter and getter macros called HeapTupleHeaderGetXmin, HeapTupleHeaderSetXmin etc. It also introduces a "virtual" field xvac by defining HeapTupleHeaderGetXvac and HeapTupleHeaderSetXvac. Xvac is used by VACUUM, in fact it is stored in t_cmin. Manfred Koizar
This commit is contained in:
parent
7882179994
commit
3c35face41
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.75 2002/05/27 19:53:33 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.76 2002/06/15 19:54:23 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The old interface functions have been converted to macros
|
||||
@ -439,16 +439,16 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull)
|
||||
result = ObjectIdGetDatum(tup->t_data->t_oid);
|
||||
break;
|
||||
case MinTransactionIdAttributeNumber:
|
||||
result = TransactionIdGetDatum(tup->t_data->t_xmin);
|
||||
result = TransactionIdGetDatum(HeapTupleHeaderGetXmin(tup->t_data));
|
||||
break;
|
||||
case MinCommandIdAttributeNumber:
|
||||
result = CommandIdGetDatum(tup->t_data->t_cmin);
|
||||
result = CommandIdGetDatum(HeapTupleHeaderGetCmin(tup->t_data));
|
||||
break;
|
||||
case MaxTransactionIdAttributeNumber:
|
||||
result = TransactionIdGetDatum(tup->t_data->t_xmax);
|
||||
result = TransactionIdGetDatum(HeapTupleHeaderGetXmax(tup->t_data));
|
||||
break;
|
||||
case MaxCommandIdAttributeNumber:
|
||||
result = CommandIdGetDatum(tup->t_data->t_cmax);
|
||||
result = CommandIdGetDatum(HeapTupleHeaderGetCmax(tup->t_data));
|
||||
break;
|
||||
case TableOidAttributeNumber:
|
||||
result = ObjectIdGetDatum(tup->t_tableOid);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.137 2002/05/24 19:52:43 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.138 2002/06/15 19:54:23 momjian Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@ -1122,10 +1122,10 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
|
||||
CheckMaxObjectId(tup->t_data->t_oid);
|
||||
}
|
||||
|
||||
TransactionIdStore(GetCurrentTransactionId(), &(tup->t_data->t_xmin));
|
||||
tup->t_data->t_cmin = cid;
|
||||
StoreInvalidTransactionId(&(tup->t_data->t_xmax));
|
||||
tup->t_data->t_cmax = FirstCommandId;
|
||||
HeapTupleHeaderSetXmin(tup->t_data, GetCurrentTransactionId());
|
||||
HeapTupleHeaderSetCmin(tup->t_data, cid);
|
||||
HeapTupleHeaderSetXmaxInvalid(tup->t_data);
|
||||
HeapTupleHeaderSetCmax(tup->t_data, FirstCommandId);
|
||||
tup->t_data->t_infomask &= ~(HEAP_XACT_MASK);
|
||||
tup->t_data->t_infomask |= HEAP_XMAX_INVALID;
|
||||
tup->t_tableOid = relation->rd_id;
|
||||
@ -1270,7 +1270,7 @@ l1:
|
||||
}
|
||||
else if (result == HeapTupleBeingUpdated)
|
||||
{
|
||||
TransactionId xwait = tp.t_data->t_xmax;
|
||||
TransactionId xwait = HeapTupleHeaderGetXmax(tp.t_data);
|
||||
|
||||
/* sleep until concurrent transaction ends */
|
||||
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
|
||||
@ -1285,7 +1285,7 @@ l1:
|
||||
* update then some other xaction could update this tuple before
|
||||
* we got to this point.
|
||||
*/
|
||||
if (!TransactionIdEquals(tp.t_data->t_xmax, xwait))
|
||||
if (!TransactionIdEquals(HeapTupleHeaderGetXmax(tp.t_data), xwait))
|
||||
goto l1;
|
||||
if (!(tp.t_data->t_infomask & HEAP_XMAX_COMMITTED))
|
||||
{
|
||||
@ -1309,10 +1309,10 @@ l1:
|
||||
|
||||
START_CRIT_SECTION();
|
||||
/* store transaction information of xact deleting the tuple */
|
||||
TransactionIdStore(GetCurrentTransactionId(), &(tp.t_data->t_xmax));
|
||||
tp.t_data->t_cmax = cid;
|
||||
tp.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
|
||||
HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE);
|
||||
HeapTupleHeaderSetXmax(tp.t_data, GetCurrentTransactionId());
|
||||
HeapTupleHeaderSetCmax(tp.t_data, cid);
|
||||
/* XLOG stuff */
|
||||
{
|
||||
xl_heap_delete xlrec;
|
||||
@ -1461,7 +1461,7 @@ l2:
|
||||
}
|
||||
else if (result == HeapTupleBeingUpdated)
|
||||
{
|
||||
TransactionId xwait = oldtup.t_data->t_xmax;
|
||||
TransactionId xwait = HeapTupleHeaderGetXmax(oldtup.t_data);
|
||||
|
||||
/* sleep untill concurrent transaction ends */
|
||||
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
|
||||
@ -1476,7 +1476,7 @@ l2:
|
||||
* update then some other xaction could update this tuple before
|
||||
* we got to this point.
|
||||
*/
|
||||
if (!TransactionIdEquals(oldtup.t_data->t_xmax, xwait))
|
||||
if (!TransactionIdEquals(HeapTupleHeaderGetXmax(oldtup.t_data), xwait))
|
||||
goto l2;
|
||||
if (!(oldtup.t_data->t_infomask & HEAP_XMAX_COMMITTED))
|
||||
{
|
||||
@ -1500,11 +1500,11 @@ l2:
|
||||
|
||||
/* Fill in OID and transaction status data for newtup */
|
||||
newtup->t_data->t_oid = oldtup.t_data->t_oid;
|
||||
TransactionIdStore(GetCurrentTransactionId(), &(newtup->t_data->t_xmin));
|
||||
newtup->t_data->t_cmin = cid;
|
||||
StoreInvalidTransactionId(&(newtup->t_data->t_xmax));
|
||||
newtup->t_data->t_infomask &= ~(HEAP_XACT_MASK);
|
||||
newtup->t_data->t_infomask |= (HEAP_XMAX_INVALID | HEAP_UPDATED);
|
||||
HeapTupleHeaderSetXmin(newtup->t_data, GetCurrentTransactionId());
|
||||
HeapTupleHeaderSetCmin(newtup->t_data, cid);
|
||||
HeapTupleHeaderSetXmaxInvalid(newtup->t_data);
|
||||
|
||||
/*
|
||||
* If the toaster needs to be activated, OR if the new tuple will not
|
||||
@ -1538,13 +1538,12 @@ l2:
|
||||
_locked_tuple_.tid = oldtup.t_self;
|
||||
XactPushRollback(_heap_unlock_tuple, (void *) &_locked_tuple_);
|
||||
|
||||
TransactionIdStore(GetCurrentTransactionId(),
|
||||
&(oldtup.t_data->t_xmax));
|
||||
oldtup.t_data->t_cmax = cid;
|
||||
oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
|
||||
HEAP_XMAX_INVALID |
|
||||
HEAP_MARKED_FOR_UPDATE);
|
||||
oldtup.t_data->t_infomask |= HEAP_XMAX_UNLOGGED;
|
||||
HeapTupleHeaderSetXmax(oldtup.t_data, GetCurrentTransactionId());
|
||||
HeapTupleHeaderSetCmax(oldtup.t_data, cid);
|
||||
already_marked = true;
|
||||
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
|
||||
|
||||
@ -1630,12 +1629,11 @@ l2:
|
||||
}
|
||||
else
|
||||
{
|
||||
TransactionIdStore(GetCurrentTransactionId(),
|
||||
&(oldtup.t_data->t_xmax));
|
||||
oldtup.t_data->t_cmax = cid;
|
||||
oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
|
||||
HEAP_XMAX_INVALID |
|
||||
HEAP_MARKED_FOR_UPDATE);
|
||||
HeapTupleHeaderSetXmax(oldtup.t_data, GetCurrentTransactionId());
|
||||
HeapTupleHeaderSetCmax(oldtup.t_data, cid);
|
||||
}
|
||||
|
||||
/* record address of new tuple in t_ctid of old one */
|
||||
@ -1759,7 +1757,7 @@ l3:
|
||||
}
|
||||
else if (result == HeapTupleBeingUpdated)
|
||||
{
|
||||
TransactionId xwait = tuple->t_data->t_xmax;
|
||||
TransactionId xwait = HeapTupleHeaderGetXmax(tuple->t_data);
|
||||
|
||||
/* sleep untill concurrent transaction ends */
|
||||
LockBuffer(*buffer, BUFFER_LOCK_UNLOCK);
|
||||
@ -1774,7 +1772,7 @@ l3:
|
||||
* update then some other xaction could update this tuple before
|
||||
* we got to this point.
|
||||
*/
|
||||
if (!TransactionIdEquals(tuple->t_data->t_xmax, xwait))
|
||||
if (!TransactionIdEquals(HeapTupleHeaderGetXmax(tuple->t_data), xwait))
|
||||
goto l3;
|
||||
if (!(tuple->t_data->t_infomask & HEAP_XMAX_COMMITTED))
|
||||
{
|
||||
@ -1802,10 +1800,10 @@ l3:
|
||||
((PageHeader) BufferGetPage(*buffer))->pd_sui = ThisStartUpID;
|
||||
|
||||
/* store transaction information of xact marking the tuple */
|
||||
TransactionIdStore(GetCurrentTransactionId(), &(tuple->t_data->t_xmax));
|
||||
tuple->t_data->t_cmax = cid;
|
||||
tuple->t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
|
||||
tuple->t_data->t_infomask |= HEAP_MARKED_FOR_UPDATE;
|
||||
HeapTupleHeaderSetXmax(tuple->t_data, GetCurrentTransactionId());
|
||||
HeapTupleHeaderSetCmax(tuple->t_data, cid);
|
||||
|
||||
LockBuffer(*buffer, BUFFER_LOCK_UNLOCK);
|
||||
|
||||
@ -1981,15 +1979,17 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from,
|
||||
if (move) /* remember xmin & xmax */
|
||||
{
|
||||
TransactionId xmax;
|
||||
TransactionId xmin;
|
||||
|
||||
if (newtup->t_data->t_infomask & HEAP_XMAX_INVALID ||
|
||||
newtup->t_data->t_infomask & HEAP_MARKED_FOR_UPDATE)
|
||||
xmax = InvalidTransactionId;
|
||||
else
|
||||
xmax = newtup->t_data->t_xmax;
|
||||
xmax = HeapTupleHeaderGetXmax(newtup->t_data);
|
||||
xmin = HeapTupleHeaderGetXmin(newtup->t_data);
|
||||
memcpy((char *) &xlhdr + hsize, &xmax, sizeof(TransactionId));
|
||||
memcpy((char *) &xlhdr + hsize + sizeof(TransactionId),
|
||||
&(newtup->t_data->t_xmin), sizeof(TransactionId));
|
||||
&xmin, sizeof(TransactionId));
|
||||
hsize += 2 * sizeof(TransactionId);
|
||||
}
|
||||
rdata[2].buffer = newbuf;
|
||||
@ -2126,10 +2126,10 @@ heap_xlog_delete(bool redo, XLogRecPtr lsn, XLogRecord *record)
|
||||
|
||||
if (redo)
|
||||
{
|
||||
htup->t_xmax = record->xl_xid;
|
||||
htup->t_cmax = FirstCommandId;
|
||||
htup->t_infomask &= ~(HEAP_XMAX_COMMITTED |
|
||||
HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE);
|
||||
HeapTupleHeaderSetXmax(htup, record->xl_xid);
|
||||
HeapTupleHeaderSetCmax(htup, FirstCommandId);
|
||||
PageSetLSN(page, lsn);
|
||||
PageSetSUI(page, ThisStartUpID);
|
||||
UnlockAndWriteBuffer(buffer);
|
||||
@ -2201,11 +2201,11 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record)
|
||||
htup->t_oid = xlhdr.t_oid;
|
||||
htup->t_natts = xlhdr.t_natts;
|
||||
htup->t_hoff = xlhdr.t_hoff;
|
||||
htup->t_xmin = record->xl_xid;
|
||||
htup->t_cmin = FirstCommandId;
|
||||
htup->t_xmax = InvalidTransactionId;
|
||||
htup->t_cmax = FirstCommandId;
|
||||
htup->t_infomask = HEAP_XMAX_INVALID | xlhdr.mask;
|
||||
HeapTupleHeaderSetXmin(htup, record->xl_xid);
|
||||
HeapTupleHeaderSetCmin(htup, FirstCommandId);
|
||||
HeapTupleHeaderSetXmax(htup, InvalidTransactionId);
|
||||
HeapTupleHeaderSetCmax(htup, FirstCommandId);
|
||||
|
||||
offnum = PageAddItem(page, (Item) htup, newlen, offnum,
|
||||
LP_USED | OverwritePageMode);
|
||||
@ -2286,17 +2286,17 @@ heap_xlog_update(bool redo, XLogRecPtr lsn, XLogRecord *record, bool move)
|
||||
{
|
||||
if (move)
|
||||
{
|
||||
TransactionIdStore(record->xl_xid, (TransactionId *) &(htup->t_cmin));
|
||||
htup->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN);
|
||||
htup->t_infomask |= HEAP_MOVED_OFF;
|
||||
HeapTupleHeaderSetXvac(htup, record->xl_xid);
|
||||
}
|
||||
else
|
||||
{
|
||||
htup->t_xmax = record->xl_xid;
|
||||
htup->t_cmax = FirstCommandId;
|
||||
htup->t_infomask &= ~(HEAP_XMAX_COMMITTED |
|
||||
HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE);
|
||||
HeapTupleHeaderSetXmax(htup, record->xl_xid);
|
||||
HeapTupleHeaderSetCmax(htup, FirstCommandId);
|
||||
}
|
||||
if (samepage)
|
||||
goto newsame;
|
||||
@ -2372,26 +2372,27 @@ newsame:;
|
||||
htup->t_hoff = xlhdr.t_hoff;
|
||||
if (move)
|
||||
{
|
||||
TransactionId xmax;
|
||||
TransactionId xmin;
|
||||
|
||||
hsize = SizeOfHeapUpdate + SizeOfHeapHeader;
|
||||
memcpy(&(htup->t_xmax),
|
||||
(char *) xlrec + hsize,
|
||||
sizeof(TransactionId));
|
||||
memcpy(&(htup->t_xmin),
|
||||
(char *) xlrec + hsize + sizeof(TransactionId),
|
||||
sizeof(TransactionId));
|
||||
TransactionIdStore(record->xl_xid, (TransactionId *) &(htup->t_cmin));
|
||||
memcpy(&xmax, (char *) xlrec + hsize, sizeof(TransactionId));
|
||||
memcpy(&xmin, (char *) xlrec + hsize + sizeof(TransactionId), sizeof(TransactionId));
|
||||
htup->t_infomask = xlhdr.mask;
|
||||
htup->t_infomask &= ~(HEAP_XMIN_COMMITTED |
|
||||
HEAP_XMIN_INVALID | HEAP_MOVED_OFF);
|
||||
htup->t_infomask |= HEAP_MOVED_IN;
|
||||
HeapTupleHeaderSetXmin(htup, xmin);
|
||||
HeapTupleHeaderSetXmax(htup, xmax);
|
||||
HeapTupleHeaderSetXvac(htup, record->xl_xid);
|
||||
}
|
||||
else
|
||||
{
|
||||
htup->t_xmin = record->xl_xid;
|
||||
htup->t_cmin = FirstCommandId;
|
||||
htup->t_xmax = InvalidTransactionId;
|
||||
htup->t_cmax = FirstCommandId;
|
||||
htup->t_infomask = HEAP_XMAX_INVALID | xlhdr.mask;
|
||||
HeapTupleHeaderSetXmin(htup, record->xl_xid);
|
||||
HeapTupleHeaderSetCmin(htup, FirstCommandId);
|
||||
HeapTupleHeaderSetXmaxInvalid(htup);
|
||||
HeapTupleHeaderSetCmax(htup, FirstCommandId);
|
||||
}
|
||||
|
||||
offnum = PageAddItem(page, (Item) htup, newlen, offnum,
|
||||
@ -2445,7 +2446,7 @@ _heap_unlock_tuple(void *data)
|
||||
|
||||
htup = (HeapTupleHeader) PageGetItem(page, lp);
|
||||
|
||||
if (!TransactionIdEquals(htup->t_xmax, GetCurrentTransactionId()))
|
||||
if (!TransactionIdEquals(HeapTupleHeaderGetXmax(htup), GetCurrentTransactionId()))
|
||||
elog(PANIC, "_heap_unlock_tuple: invalid xmax in rollback");
|
||||
htup->t_infomask &= ~HEAP_XMAX_UNLOGGED;
|
||||
htup->t_infomask |= HEAP_XMAX_INVALID;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.23 2002/03/31 06:26:29 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.24 2002/06/15 19:54:23 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -73,7 +73,8 @@ XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr,
|
||||
htup = (HeapTupleHeader) PageGetItem(page, lp);
|
||||
|
||||
Assert(PageGetSUI(page) == ThisStartUpID);
|
||||
if (!TransactionIdEquals(htup->t_xmin, xid) || htup->t_cmin != cid)
|
||||
if (!TransactionIdEquals(HeapTupleHeaderGetXmin(htup), xid) ||
|
||||
HeapTupleHeaderGetCmin(htup) != cid)
|
||||
{
|
||||
UnlockAndReleaseBuffer(buffer);
|
||||
return (-1);
|
||||
@ -137,8 +138,8 @@ XLogIsValidTuple(RelFileNode hnode, ItemPointer iptr)
|
||||
{
|
||||
if (htup->t_infomask & HEAP_XMIN_INVALID ||
|
||||
(htup->t_infomask & HEAP_MOVED_IN &&
|
||||
TransactionIdDidAbort((TransactionId) htup->t_cmin)) ||
|
||||
TransactionIdDidAbort(htup->t_xmin))
|
||||
TransactionIdDidAbort(HeapTupleHeaderGetXvac(htup))) ||
|
||||
TransactionIdDidAbort(HeapTupleHeaderGetXmin(htup)))
|
||||
{
|
||||
UnlockAndReleaseBuffer(buffer);
|
||||
return (false);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.179 2002/05/21 22:05:53 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.180 2002/06/15 19:54:23 momjian Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@ -1621,7 +1621,8 @@ IndexBuildHeapScan(Relation heapRelation,
|
||||
* (Consider INSERT followed by CREATE INDEX within a
|
||||
* transaction.)
|
||||
*/
|
||||
if (!TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmin))
|
||||
if (!TransactionIdIsCurrentTransactionId(
|
||||
HeapTupleHeaderGetXmin(heapTuple->t_data)))
|
||||
elog(ERROR, "IndexBuildHeapScan: concurrent insert in progress");
|
||||
indexIt = true;
|
||||
tupleIsAlive = true;
|
||||
@ -1635,7 +1636,8 @@ IndexBuildHeapScan(Relation heapRelation,
|
||||
* (Consider DELETE followed by CREATE INDEX within a
|
||||
* transaction.)
|
||||
*/
|
||||
if (!TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmax))
|
||||
if (!TransactionIdIsCurrentTransactionId(
|
||||
HeapTupleHeaderGetXmax(heapTuple->t_data)))
|
||||
elog(ERROR, "IndexBuildHeapScan: concurrent delete in progress");
|
||||
indexIt = true;
|
||||
tupleIsAlive = false;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.79 2002/05/22 21:40:55 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.80 2002/06/15 19:54:23 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -249,10 +249,10 @@ DefineSequence(CreateSeqStmt *seq)
|
||||
itemId = PageGetItemId((Page) page, FirstOffsetNumber);
|
||||
item = PageGetItem((Page) page, itemId);
|
||||
|
||||
((HeapTupleHeader) item)->t_xmin = FrozenTransactionId;
|
||||
HeapTupleHeaderSetXmin((HeapTupleHeader) item, FrozenTransactionId);
|
||||
((HeapTupleHeader) item)->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
|
||||
tuple->t_data->t_xmin = FrozenTransactionId;
|
||||
HeapTupleHeaderSetXmin(tuple->t_data, FrozenTransactionId);
|
||||
tuple->t_data->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.227 2002/06/13 19:52:02 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.228 2002/06/15 19:54:23 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1080,11 +1080,11 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
|
||||
* Tuple is good. Consider whether to replace its
|
||||
* xmin value with FrozenTransactionId.
|
||||
*/
|
||||
if (TransactionIdIsNormal(tuple.t_data->t_xmin) &&
|
||||
TransactionIdPrecedes(tuple.t_data->t_xmin,
|
||||
if (TransactionIdIsNormal(HeapTupleHeaderGetXmin(tuple.t_data)) &&
|
||||
TransactionIdPrecedes(HeapTupleHeaderGetXmin(tuple.t_data),
|
||||
FreezeLimit))
|
||||
{
|
||||
tuple.t_data->t_xmin = FrozenTransactionId;
|
||||
HeapTupleHeaderSetXmin(tuple.t_data, FrozenTransactionId);
|
||||
/* infomask should be okay already */
|
||||
Assert(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED);
|
||||
pgchanged = true;
|
||||
@ -1127,7 +1127,7 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
|
||||
* lock on the relation; shouldn't we raise an error?
|
||||
*/
|
||||
elog(WARNING, "Rel %s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation",
|
||||
relname, blkno, offnum, tuple.t_data->t_xmin);
|
||||
relname, blkno, offnum, HeapTupleHeaderGetXmin(tuple.t_data));
|
||||
do_shrinking = false;
|
||||
break;
|
||||
case HEAPTUPLE_DELETE_IN_PROGRESS:
|
||||
@ -1137,7 +1137,7 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
|
||||
* lock on the relation; shouldn't we raise an error?
|
||||
*/
|
||||
elog(WARNING, "Rel %s: TID %u/%u: DeleteTransactionInProgress %u - can't shrink relation",
|
||||
relname, blkno, offnum, tuple.t_data->t_xmax);
|
||||
relname, blkno, offnum, HeapTupleHeaderGetXmax(tuple.t_data));
|
||||
do_shrinking = false;
|
||||
break;
|
||||
default:
|
||||
@ -1513,8 +1513,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
|
||||
if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
{
|
||||
if ((TransactionId) tuple.t_data->t_cmin != myXID)
|
||||
elog(ERROR, "Invalid XID in t_cmin");
|
||||
if (HeapTupleHeaderGetXvac(tuple.t_data) != myXID)
|
||||
elog(ERROR, "Invalid XVAC in tuple header");
|
||||
if (tuple.t_data->t_infomask & HEAP_MOVED_IN)
|
||||
elog(ERROR, "HEAP_MOVED_IN was not expected");
|
||||
|
||||
@ -1558,7 +1558,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
* tuples to another places.
|
||||
*/
|
||||
if ((tuple.t_data->t_infomask & HEAP_UPDATED &&
|
||||
!TransactionIdPrecedes(tuple.t_data->t_xmin, OldestXmin)) ||
|
||||
!TransactionIdPrecedes(HeapTupleHeaderGetXmin(tuple.t_data),
|
||||
OldestXmin)) ||
|
||||
(!(tuple.t_data->t_infomask & HEAP_XMAX_INVALID) &&
|
||||
!(ItemPointerEquals(&(tuple.t_self),
|
||||
&(tuple.t_data->t_ctid)))))
|
||||
@ -1675,7 +1676,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
|
||||
/* All done ? */
|
||||
if (!(tp.t_data->t_infomask & HEAP_UPDATED) ||
|
||||
TransactionIdPrecedes(tp.t_data->t_xmin, OldestXmin))
|
||||
TransactionIdPrecedes(HeapTupleHeaderGetXmin(tp.t_data),
|
||||
OldestXmin))
|
||||
break;
|
||||
|
||||
/* Well, try to find tuple with old row version */
|
||||
@ -1723,8 +1725,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
* latter, and we are too close to 6.5 release. -
|
||||
* vadim 06/11/99
|
||||
*/
|
||||
if (!(TransactionIdEquals(Ptp.t_data->t_xmax,
|
||||
tp.t_data->t_xmin)))
|
||||
if (!(TransactionIdEquals(HeapTupleHeaderGetXmax(Ptp.t_data),
|
||||
HeapTupleHeaderGetXmin(tp.t_data))))
|
||||
{
|
||||
if (freeCbuf)
|
||||
ReleaseBuffer(Cbuf);
|
||||
@ -1749,14 +1751,13 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
* removed.
|
||||
*/
|
||||
if (Ptp.t_data->t_infomask & HEAP_UPDATED &&
|
||||
TransactionIdEquals(Ptp.t_data->t_xmin,
|
||||
Ptp.t_data->t_xmax))
|
||||
TransactionIdEquals(HeapTupleHeaderGetXmin(Ptp.t_data),
|
||||
HeapTupleHeaderGetXmax(Ptp.t_data)))
|
||||
{
|
||||
TransactionIdStore(myXID,
|
||||
(TransactionId *) &(Ptp.t_data->t_cmin));
|
||||
Ptp.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN);
|
||||
Ptp.t_data->t_infomask |= HEAP_MOVED_OFF;
|
||||
HeapTupleHeaderSetXvac(Ptp.t_data, myXID);
|
||||
WriteBuffer(Pbuf);
|
||||
continue;
|
||||
}
|
||||
@ -1820,10 +1821,10 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
/* NO ELOG(ERROR) TILL CHANGES ARE LOGGED */
|
||||
START_CRIT_SECTION();
|
||||
|
||||
TransactionIdStore(myXID, (TransactionId *) &(tuple.t_data->t_cmin));
|
||||
tuple.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN);
|
||||
tuple.t_data->t_infomask |= HEAP_MOVED_OFF;
|
||||
HeapTupleHeaderSetXvac(tuple.t_data, myXID);
|
||||
|
||||
/*
|
||||
* If this page was not used before - clean it.
|
||||
@ -1860,10 +1861,10 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
* Update the state of the copied tuple, and store it
|
||||
* on the destination page.
|
||||
*/
|
||||
TransactionIdStore(myXID, (TransactionId *) &(newtup.t_data->t_cmin));
|
||||
newtup.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_OFF);
|
||||
newtup.t_data->t_infomask |= HEAP_MOVED_IN;
|
||||
HeapTupleHeaderSetXvac(newtup.t_data, myXID);
|
||||
newoff = PageAddItem(ToPage, (Item) newtup.t_data, tuple_len,
|
||||
InvalidOffsetNumber, LP_USED);
|
||||
if (newoff == InvalidOffsetNumber)
|
||||
@ -1989,10 +1990,10 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
* Mark new tuple as moved_in by vacuum and store vacuum XID
|
||||
* in t_cmin !!!
|
||||
*/
|
||||
TransactionIdStore(myXID, (TransactionId *) &(newtup.t_data->t_cmin));
|
||||
newtup.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_OFF);
|
||||
newtup.t_data->t_infomask |= HEAP_MOVED_IN;
|
||||
HeapTupleHeaderSetXvac(newtup.t_data, myXID);
|
||||
|
||||
/* add tuple to the page */
|
||||
newoff = PageAddItem(ToPage, (Item) newtup.t_data, tuple_len,
|
||||
@ -2015,10 +2016,10 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
* Mark old tuple as moved_off by vacuum and store vacuum XID
|
||||
* in t_cmin !!!
|
||||
*/
|
||||
TransactionIdStore(myXID, (TransactionId *) &(tuple.t_data->t_cmin));
|
||||
tuple.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN);
|
||||
tuple.t_data->t_infomask |= HEAP_MOVED_OFF;
|
||||
HeapTupleHeaderSetXvac(tuple.t_data, myXID);
|
||||
|
||||
{
|
||||
XLogRecPtr recptr =
|
||||
@ -2066,8 +2067,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
|
||||
if (tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)
|
||||
continue;
|
||||
if ((TransactionId) tuple.t_data->t_cmin != myXID)
|
||||
elog(ERROR, "Invalid XID in t_cmin (4)");
|
||||
if (HeapTupleHeaderGetXvac(tuple.t_data) != myXID)
|
||||
elog(ERROR, "Invalid XVAC in tuple header (4)");
|
||||
if (tuple.t_data->t_infomask & HEAP_MOVED_IN)
|
||||
elog(ERROR, "HEAP_MOVED_IN was not expected (2)");
|
||||
if (tuple.t_data->t_infomask & HEAP_MOVED_OFF)
|
||||
@ -2204,8 +2205,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
|
||||
if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
{
|
||||
if ((TransactionId) tuple.t_data->t_cmin != myXID)
|
||||
elog(ERROR, "Invalid XID in t_cmin (2)");
|
||||
if (HeapTupleHeaderGetXvac(tuple.t_data) != myXID)
|
||||
elog(ERROR, "Invalid XVAC in tuple header (2)");
|
||||
if (tuple.t_data->t_infomask & HEAP_MOVED_IN)
|
||||
{
|
||||
tuple.t_data->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
@ -2283,8 +2284,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
|
||||
|
||||
if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
{
|
||||
if ((TransactionId) tuple.t_data->t_cmin != myXID)
|
||||
elog(ERROR, "Invalid XID in t_cmin (3)");
|
||||
if (HeapTupleHeaderGetXvac(tuple.t_data) != myXID)
|
||||
elog(ERROR, "Invalid XVAC in tuple header (3)");
|
||||
if (tuple.t_data->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
itemid->lp_flags &= ~LP_USED;
|
||||
|
@ -31,7 +31,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.14 2002/04/02 01:03:05 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.15 2002/06/15 19:54:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -332,11 +332,11 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
|
||||
* assumption by momentarily acquiring exclusive lock,
|
||||
* but for the moment I see no need to.
|
||||
*/
|
||||
if (TransactionIdIsNormal(tuple.t_data->t_xmin) &&
|
||||
TransactionIdPrecedes(tuple.t_data->t_xmin,
|
||||
if (TransactionIdIsNormal(HeapTupleHeaderGetXmin(tuple.t_data)) &&
|
||||
TransactionIdPrecedes(HeapTupleHeaderGetXmin(tuple.t_data),
|
||||
FreezeLimit))
|
||||
{
|
||||
tuple.t_data->t_xmin = FrozenTransactionId;
|
||||
HeapTupleHeaderSetXmin(tuple.t_data, FrozenTransactionId);
|
||||
/* infomask should be okay already */
|
||||
Assert(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED);
|
||||
pgchanged = true;
|
||||
|
@ -16,7 +16,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.54 2002/05/25 20:00:12 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.55 2002/06/15 19:54:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -73,11 +73,11 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple)
|
||||
|
||||
if (tuple->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
return false;
|
||||
if (!TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID;
|
||||
return false;
|
||||
@ -87,11 +87,11 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple)
|
||||
}
|
||||
else if (tuple->t_infomask & HEAP_MOVED_IN)
|
||||
{
|
||||
if (!TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
return false;
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
else
|
||||
{
|
||||
@ -100,21 +100,21 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TransactionIdIsCurrentTransactionId(tuple->t_xmin))
|
||||
else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
|
||||
return true;
|
||||
|
||||
Assert(TransactionIdIsCurrentTransactionId(tuple->t_xmax));
|
||||
Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)));
|
||||
|
||||
if (tuple->t_infomask & HEAP_MARKED_FOR_UPDATE)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (!TransactionIdDidCommit(tuple->t_xmin))
|
||||
else if (!TransactionIdDidCommit(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmin))
|
||||
if (TransactionIdDidAbort(HeapTupleHeaderGetXmin(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */
|
||||
return false;
|
||||
}
|
||||
@ -134,16 +134,16 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple)
|
||||
return false; /* updated by other */
|
||||
}
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId(tuple->t_xmax))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
if (tuple->t_infomask & HEAP_MARKED_FOR_UPDATE)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TransactionIdDidCommit(tuple->t_xmax))
|
||||
if (!TransactionIdDidCommit(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmax))
|
||||
if (TransactionIdDidAbort(HeapTupleHeaderGetXmax(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID; /* aborted */
|
||||
return true;
|
||||
}
|
||||
@ -209,11 +209,11 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple)
|
||||
|
||||
if (tuple->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
return false;
|
||||
if (!TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID;
|
||||
return false;
|
||||
@ -223,11 +223,11 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple)
|
||||
}
|
||||
else if (tuple->t_infomask & HEAP_MOVED_IN)
|
||||
{
|
||||
if (!TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
return false;
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
else
|
||||
{
|
||||
@ -236,27 +236,27 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TransactionIdIsCurrentTransactionId(tuple->t_xmin))
|
||||
else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
if (tuple->t_cmin >= GetCurrentCommandId())
|
||||
if (HeapTupleHeaderGetCmin(tuple) >= GetCurrentCommandId())
|
||||
return false; /* inserted after scan started */
|
||||
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
|
||||
return true;
|
||||
|
||||
Assert(TransactionIdIsCurrentTransactionId(tuple->t_xmax));
|
||||
Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)));
|
||||
|
||||
if (tuple->t_infomask & HEAP_MARKED_FOR_UPDATE)
|
||||
return true;
|
||||
|
||||
if (tuple->t_cmax >= GetCurrentCommandId())
|
||||
if (HeapTupleHeaderGetCmax(tuple) >= GetCurrentCommandId())
|
||||
return true; /* deleted after scan started */
|
||||
else
|
||||
return false; /* deleted before scan started */
|
||||
}
|
||||
else if (!TransactionIdDidCommit(tuple->t_xmin))
|
||||
else if (!TransactionIdDidCommit(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmin))
|
||||
if (TransactionIdDidAbort(HeapTupleHeaderGetXmin(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */
|
||||
return false;
|
||||
}
|
||||
@ -276,19 +276,19 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId(tuple->t_xmax))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
if (tuple->t_infomask & HEAP_MARKED_FOR_UPDATE)
|
||||
return true;
|
||||
if (tuple->t_cmax >= GetCurrentCommandId())
|
||||
if (HeapTupleHeaderGetCmax(tuple) >= GetCurrentCommandId())
|
||||
return true; /* deleted after scan started */
|
||||
else
|
||||
return false; /* deleted before scan started */
|
||||
}
|
||||
|
||||
if (!TransactionIdDidCommit(tuple->t_xmax))
|
||||
if (!TransactionIdDidCommit(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmax))
|
||||
if (TransactionIdDidAbort(HeapTupleHeaderGetXmax(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID; /* aborted */
|
||||
return true;
|
||||
}
|
||||
@ -326,11 +326,11 @@ HeapTupleSatisfiesToast(HeapTupleHeader tuple)
|
||||
|
||||
if (tuple->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
return false;
|
||||
if (!TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID;
|
||||
return false;
|
||||
@ -340,11 +340,11 @@ HeapTupleSatisfiesToast(HeapTupleHeader tuple)
|
||||
}
|
||||
else if (tuple->t_infomask & HEAP_MOVED_IN)
|
||||
{
|
||||
if (!TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
return false;
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
else
|
||||
{
|
||||
@ -379,11 +379,11 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid)
|
||||
|
||||
if (tuple->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
return HeapTupleInvisible;
|
||||
if (!TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID;
|
||||
return HeapTupleInvisible;
|
||||
@ -393,11 +393,11 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid)
|
||||
}
|
||||
else if (tuple->t_infomask & HEAP_MOVED_IN)
|
||||
{
|
||||
if (!TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
return HeapTupleInvisible;
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
else
|
||||
{
|
||||
@ -406,30 +406,30 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TransactionIdIsCurrentTransactionId(tuple->t_xmin))
|
||||
else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
if (tuple->t_cmin >= curcid)
|
||||
if (HeapTupleHeaderGetCmin(tuple) >= curcid)
|
||||
return HeapTupleInvisible; /* inserted after scan
|
||||
* started */
|
||||
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
|
||||
return HeapTupleMayBeUpdated;
|
||||
|
||||
Assert(TransactionIdIsCurrentTransactionId(tuple->t_xmax));
|
||||
Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)));
|
||||
|
||||
if (tuple->t_infomask & HEAP_MARKED_FOR_UPDATE)
|
||||
return HeapTupleMayBeUpdated;
|
||||
|
||||
if (tuple->t_cmax >= curcid)
|
||||
if (HeapTupleHeaderGetCmax(tuple) >= curcid)
|
||||
return HeapTupleSelfUpdated; /* updated after scan
|
||||
* started */
|
||||
else
|
||||
return HeapTupleInvisible; /* updated before scan
|
||||
* started */
|
||||
}
|
||||
else if (!TransactionIdDidCommit(tuple->t_xmin))
|
||||
else if (!TransactionIdDidCommit(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmin))
|
||||
if (TransactionIdDidAbort(HeapTupleHeaderGetXmin(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */
|
||||
return HeapTupleInvisible;
|
||||
}
|
||||
@ -449,20 +449,20 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid)
|
||||
return HeapTupleUpdated; /* updated by other */
|
||||
}
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId(tuple->t_xmax))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
if (tuple->t_infomask & HEAP_MARKED_FOR_UPDATE)
|
||||
return HeapTupleMayBeUpdated;
|
||||
if (tuple->t_cmax >= curcid)
|
||||
if (HeapTupleHeaderGetCmax(tuple) >= curcid)
|
||||
return HeapTupleSelfUpdated; /* updated after scan
|
||||
* started */
|
||||
else
|
||||
return HeapTupleInvisible; /* updated before scan started */
|
||||
}
|
||||
|
||||
if (!TransactionIdDidCommit(tuple->t_xmax))
|
||||
if (!TransactionIdDidCommit(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmax))
|
||||
if (TransactionIdDidAbort(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID; /* aborted */
|
||||
return HeapTupleMayBeUpdated;
|
||||
@ -510,11 +510,11 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple)
|
||||
|
||||
if (tuple->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
return false;
|
||||
if (!TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID;
|
||||
return false;
|
||||
@ -524,11 +524,11 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple)
|
||||
}
|
||||
else if (tuple->t_infomask & HEAP_MOVED_IN)
|
||||
{
|
||||
if (!TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
return false;
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
else
|
||||
{
|
||||
@ -537,26 +537,26 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TransactionIdIsCurrentTransactionId(tuple->t_xmin))
|
||||
else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
|
||||
return true;
|
||||
|
||||
Assert(TransactionIdIsCurrentTransactionId(tuple->t_xmax));
|
||||
Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)));
|
||||
|
||||
if (tuple->t_infomask & HEAP_MARKED_FOR_UPDATE)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (!TransactionIdDidCommit(tuple->t_xmin))
|
||||
else if (!TransactionIdDidCommit(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmin))
|
||||
if (TransactionIdDidAbort(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID;
|
||||
return false;
|
||||
}
|
||||
SnapshotDirty->xmin = tuple->t_xmin;
|
||||
SnapshotDirty->xmin = HeapTupleHeaderGetXmin(tuple);
|
||||
/* XXX shouldn't we fall through to look at xmax? */
|
||||
return true; /* in insertion by other */
|
||||
}
|
||||
@ -577,22 +577,22 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple)
|
||||
return false; /* updated by other */
|
||||
}
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId(tuple->t_xmax))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
if (tuple->t_infomask & HEAP_MARKED_FOR_UPDATE)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TransactionIdDidCommit(tuple->t_xmax))
|
||||
if (!TransactionIdDidCommit(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmax))
|
||||
if (TransactionIdDidAbort(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID; /* aborted */
|
||||
return true;
|
||||
}
|
||||
/* running xact */
|
||||
SnapshotDirty->xmax = tuple->t_xmax;
|
||||
SnapshotDirty->xmax = HeapTupleHeaderGetXmax(tuple);
|
||||
return true; /* in updation by other */
|
||||
}
|
||||
|
||||
@ -641,11 +641,11 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
|
||||
|
||||
if (tuple->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
return false;
|
||||
if (!TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID;
|
||||
return false;
|
||||
@ -655,11 +655,11 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
|
||||
}
|
||||
else if (tuple->t_infomask & HEAP_MOVED_IN)
|
||||
{
|
||||
if (!TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
if (TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
return false;
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
else
|
||||
{
|
||||
@ -668,27 +668,27 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TransactionIdIsCurrentTransactionId(tuple->t_xmin))
|
||||
else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
if (tuple->t_cmin >= snapshot->curcid)
|
||||
if (HeapTupleHeaderGetCmin(tuple) >= snapshot->curcid)
|
||||
return false; /* inserted after scan started */
|
||||
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
|
||||
return true;
|
||||
|
||||
Assert(TransactionIdIsCurrentTransactionId(tuple->t_xmax));
|
||||
Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)));
|
||||
|
||||
if (tuple->t_infomask & HEAP_MARKED_FOR_UPDATE)
|
||||
return true;
|
||||
|
||||
if (tuple->t_cmax >= snapshot->curcid)
|
||||
if (HeapTupleHeaderGetCmax(tuple) >= snapshot->curcid)
|
||||
return true; /* deleted after scan started */
|
||||
else
|
||||
return false; /* deleted before scan started */
|
||||
}
|
||||
else if (!TransactionIdDidCommit(tuple->t_xmin))
|
||||
else if (!TransactionIdDidCommit(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmin))
|
||||
if (TransactionIdDidAbort(HeapTupleHeaderGetXmin(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID;
|
||||
return false;
|
||||
}
|
||||
@ -700,15 +700,19 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
|
||||
* By here, the inserting transaction has committed - have to check
|
||||
* when...
|
||||
*/
|
||||
if (TransactionIdFollowsOrEquals(tuple->t_xmin, snapshot->xmin))
|
||||
if (TransactionIdFollowsOrEquals(HeapTupleHeaderGetXmin(tuple),
|
||||
snapshot->xmin))
|
||||
{
|
||||
uint32 i;
|
||||
|
||||
if (TransactionIdFollowsOrEquals(tuple->t_xmin, snapshot->xmax))
|
||||
if (TransactionIdFollowsOrEquals(HeapTupleHeaderGetXmin(tuple),
|
||||
snapshot->xmax))
|
||||
return false;
|
||||
|
||||
for (i = 0; i < snapshot->xcnt; i++)
|
||||
{
|
||||
if (TransactionIdEquals(tuple->t_xmin, snapshot->xip[i]))
|
||||
if (TransactionIdEquals(HeapTupleHeaderGetXmin(tuple),
|
||||
snapshot->xip[i]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -721,17 +725,17 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
|
||||
|
||||
if (!(tuple->t_infomask & HEAP_XMAX_COMMITTED))
|
||||
{
|
||||
if (TransactionIdIsCurrentTransactionId(tuple->t_xmax))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
if (tuple->t_cmax >= snapshot->curcid)
|
||||
if (HeapTupleHeaderGetCmax(tuple) >= snapshot->curcid)
|
||||
return true; /* deleted after scan started */
|
||||
else
|
||||
return false; /* deleted before scan started */
|
||||
}
|
||||
|
||||
if (!TransactionIdDidCommit(tuple->t_xmax))
|
||||
if (!TransactionIdDidCommit(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmax))
|
||||
if (TransactionIdDidAbort(HeapTupleHeaderGetXmax(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID; /* aborted */
|
||||
return true;
|
||||
}
|
||||
@ -743,15 +747,16 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
|
||||
/*
|
||||
* OK, the deleting transaction committed too ... but when?
|
||||
*/
|
||||
if (TransactionIdFollowsOrEquals(tuple->t_xmax, snapshot->xmin))
|
||||
if (TransactionIdFollowsOrEquals(HeapTupleHeaderGetXmax(tuple), snapshot->xmin))
|
||||
{
|
||||
uint32 i;
|
||||
|
||||
if (TransactionIdFollowsOrEquals(tuple->t_xmax, snapshot->xmax))
|
||||
if (TransactionIdFollowsOrEquals(HeapTupleHeaderGetXmax(tuple),
|
||||
snapshot->xmax))
|
||||
return true;
|
||||
for (i = 0; i < snapshot->xcnt; i++)
|
||||
{
|
||||
if (TransactionIdEquals(tuple->t_xmax, snapshot->xip[i]))
|
||||
if (TransactionIdEquals(HeapTupleHeaderGetXmax(tuple), snapshot->xip[i]))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -794,11 +799,11 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
|
||||
return HEAPTUPLE_DEAD;
|
||||
else if (tuple->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
return HEAPTUPLE_DELETE_IN_PROGRESS;
|
||||
if (TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
return HEAPTUPLE_DELETE_IN_PROGRESS;
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID;
|
||||
return HEAPTUPLE_DEAD;
|
||||
@ -807,11 +812,11 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
|
||||
}
|
||||
else if (tuple->t_infomask & HEAP_MOVED_IN)
|
||||
{
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
|
||||
return HEAPTUPLE_INSERT_IN_PROGRESS;
|
||||
if (TransactionIdIsInProgress((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
|
||||
return HEAPTUPLE_INSERT_IN_PROGRESS;
|
||||
if (TransactionIdDidCommit((TransactionId) tuple->t_cmin))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
else
|
||||
{
|
||||
@ -819,11 +824,11 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
|
||||
return HEAPTUPLE_DEAD;
|
||||
}
|
||||
}
|
||||
else if (TransactionIdIsInProgress(tuple->t_xmin))
|
||||
else if (TransactionIdIsInProgress(HeapTupleHeaderGetXmin(tuple)))
|
||||
return HEAPTUPLE_INSERT_IN_PROGRESS;
|
||||
else if (TransactionIdDidCommit(tuple->t_xmin))
|
||||
else if (TransactionIdDidCommit(HeapTupleHeaderGetXmin(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
else if (TransactionIdDidAbort(tuple->t_xmin))
|
||||
else if (TransactionIdDidAbort(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID;
|
||||
return HEAPTUPLE_DEAD;
|
||||
@ -858,9 +863,9 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
|
||||
*/
|
||||
if (!(tuple->t_infomask & HEAP_XMAX_COMMITTED))
|
||||
{
|
||||
if (TransactionIdIsInProgress(tuple->t_xmax))
|
||||
if (TransactionIdIsInProgress(HeapTupleHeaderGetXmax(tuple)))
|
||||
return HEAPTUPLE_LIVE;
|
||||
if (TransactionIdDidCommit(tuple->t_xmax))
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXmax(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMAX_COMMITTED;
|
||||
else /* it's either aborted or crashed */
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID;
|
||||
@ -870,11 +875,11 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
|
||||
|
||||
if (!(tuple->t_infomask & HEAP_XMAX_COMMITTED))
|
||||
{
|
||||
if (TransactionIdIsInProgress(tuple->t_xmax))
|
||||
if (TransactionIdIsInProgress(HeapTupleHeaderGetXmax(tuple)))
|
||||
return HEAPTUPLE_DELETE_IN_PROGRESS;
|
||||
else if (TransactionIdDidCommit(tuple->t_xmax))
|
||||
else if (TransactionIdDidCommit(HeapTupleHeaderGetXmax(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMAX_COMMITTED;
|
||||
else if (TransactionIdDidAbort(tuple->t_xmax))
|
||||
else if (TransactionIdDidAbort(HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID;
|
||||
return HEAPTUPLE_LIVE;
|
||||
@ -896,7 +901,8 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
|
||||
* Deleter committed, but check special cases.
|
||||
*/
|
||||
|
||||
if (TransactionIdEquals(tuple->t_xmin, tuple->t_xmax))
|
||||
if (TransactionIdEquals(HeapTupleHeaderGetXmin(tuple),
|
||||
HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
/*
|
||||
* inserter also deleted it, so it was never visible to anyone
|
||||
@ -905,7 +911,7 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
|
||||
return HEAPTUPLE_DEAD;
|
||||
}
|
||||
|
||||
if (!TransactionIdPrecedes(tuple->t_xmax, OldestXmin))
|
||||
if (!TransactionIdPrecedes(HeapTupleHeaderGetXmax(tuple), OldestXmin))
|
||||
{
|
||||
/* deleting xact is too recent, tuple could still be visible */
|
||||
return HEAPTUPLE_RECENTLY_DEAD;
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: htup.h,v 1.52 2002/05/27 19:53:33 tgl Exp $
|
||||
* $Id: htup.h,v 1.53 2002/06/15 19:54:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -16,6 +16,7 @@
|
||||
|
||||
#include "storage/bufpage.h"
|
||||
#include "storage/relfilenode.h"
|
||||
#include "access/transam.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -83,6 +84,87 @@ typedef struct HeapTupleHeaderData
|
||||
|
||||
typedef HeapTupleHeaderData *HeapTupleHeader;
|
||||
|
||||
/*
|
||||
* information stored in t_infomask:
|
||||
*/
|
||||
#define HEAP_HASNULL 0x0001 /* has null attribute(s) */
|
||||
#define HEAP_HASVARLENA 0x0002 /* has variable length
|
||||
* attribute(s) */
|
||||
#define HEAP_HASEXTERNAL 0x0004 /* has external stored
|
||||
* attribute(s) */
|
||||
#define HEAP_HASCOMPRESSED 0x0008 /* has compressed stored
|
||||
* attribute(s) */
|
||||
#define HEAP_HASEXTENDED 0x000C /* the two above combined */
|
||||
|
||||
#define HEAP_XMAX_UNLOGGED 0x0080 /* to lock tuple for update */
|
||||
/* without logging */
|
||||
#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 */
|
||||
#define HEAP_XMAX_INVALID 0x0800 /* t_xmax invalid/aborted */
|
||||
#define HEAP_MARKED_FOR_UPDATE 0x1000 /* marked for UPDATE */
|
||||
#define HEAP_UPDATED 0x2000 /* this is UPDATEd version of row */
|
||||
#define HEAP_MOVED_OFF 0x4000 /* moved to another place by
|
||||
* vacuum */
|
||||
#define HEAP_MOVED_IN 0x8000 /* moved from another place by
|
||||
* vacuum */
|
||||
|
||||
#define HEAP_XACT_MASK 0xFFF0 /* visibility-related bits */
|
||||
|
||||
|
||||
|
||||
/* HeapTupleHeader accessor macros */
|
||||
|
||||
#define HeapTupleHeaderGetXmin(tup) \
|
||||
((tup)->t_xmin)
|
||||
|
||||
#define HeapTupleHeaderGetXmax(tup) \
|
||||
((tup)->t_xmax)
|
||||
|
||||
/* no AssertMacro, because this is read as a system-defined attribute also */
|
||||
#define HeapTupleHeaderGetCmin(tup) \
|
||||
( \
|
||||
(tup)->t_cmin \
|
||||
)
|
||||
|
||||
#define HeapTupleHeaderGetCmax(tup) \
|
||||
((tup)->t_cmax)
|
||||
|
||||
#define HeapTupleHeaderGetXvac(tup) \
|
||||
( \
|
||||
AssertMacro((tup)->t_infomask & (HEAP_MOVED_IN | HEAP_MOVED_OFF)), \
|
||||
(TransactionId) (tup)->t_cmin \
|
||||
)
|
||||
|
||||
|
||||
#define HeapTupleHeaderSetXmin(tup, xid) \
|
||||
(TransactionIdStore((xid), &(tup)->t_xmin))
|
||||
|
||||
#define HeapTupleHeaderSetXminInvalid(tup) \
|
||||
(StoreInvalidTransactionId(&(tup)->t_xmin))
|
||||
|
||||
#define HeapTupleHeaderSetXmax(tup, xid) \
|
||||
(TransactionIdStore((xid), &(tup)->t_xmax))
|
||||
|
||||
#define HeapTupleHeaderSetXmaxInvalid(tup) \
|
||||
(StoreInvalidTransactionId(&(tup)->t_xmax))
|
||||
|
||||
#define HeapTupleHeaderSetCmin(tup, cid) \
|
||||
( \
|
||||
AssertMacro(!((tup)->t_infomask & (HEAP_MOVED_IN | HEAP_MOVED_OFF))), \
|
||||
(tup)->t_cmin = (cid) \
|
||||
)
|
||||
|
||||
#define HeapTupleHeaderSetCmax(tup, cid) \
|
||||
((tup)->t_cmax = (cid))
|
||||
|
||||
#define HeapTupleHeaderSetXvac(tup, xid) \
|
||||
( \
|
||||
AssertMacro((tup)->t_infomask & (HEAP_MOVED_IN | HEAP_MOVED_OFF)), \
|
||||
TransactionIdStore((xid), (TransactionId *) &((tup)->t_cmin)) \
|
||||
)
|
||||
|
||||
|
||||
/*
|
||||
* XLOG allows to store some information in high 4 bits of log
|
||||
* record xl_info field
|
||||
@ -250,33 +332,6 @@ typedef HeapTupleData *HeapTuple;
|
||||
*/
|
||||
#define HeapTupleIsValid(tuple) PointerIsValid(tuple)
|
||||
|
||||
/*
|
||||
* information stored in t_infomask:
|
||||
*/
|
||||
#define HEAP_HASNULL 0x0001 /* has null attribute(s) */
|
||||
#define HEAP_HASVARLENA 0x0002 /* has variable length
|
||||
* attribute(s) */
|
||||
#define HEAP_HASEXTERNAL 0x0004 /* has external stored
|
||||
* attribute(s) */
|
||||
#define HEAP_HASCOMPRESSED 0x0008 /* has compressed stored
|
||||
* attribute(s) */
|
||||
#define HEAP_HASEXTENDED 0x000C /* the two above combined */
|
||||
|
||||
#define HEAP_XMAX_UNLOGGED 0x0080 /* to lock tuple for update
|
||||
* without logging */
|
||||
#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 */
|
||||
#define HEAP_XMAX_INVALID 0x0800 /* t_xmax invalid/aborted */
|
||||
#define HEAP_MARKED_FOR_UPDATE 0x1000 /* marked for UPDATE */
|
||||
#define HEAP_UPDATED 0x2000 /* this is UPDATEd version of row */
|
||||
#define HEAP_MOVED_OFF 0x4000 /* moved to another place by
|
||||
* vacuum */
|
||||
#define HEAP_MOVED_IN 0x8000 /* moved from another place by
|
||||
* vacuum */
|
||||
|
||||
#define HEAP_XACT_MASK 0xFFF0 /* visibility-related bits */
|
||||
|
||||
#define HeapTupleNoNulls(tuple) \
|
||||
(!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASNULL))
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
* ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.30 2002/05/05 00:03:29 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.31 2002/06/15 19:54:24 momjian Exp $
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
@ -552,8 +552,8 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
|
||||
* This is needed because CREATE OR REPLACE FUNCTION can modify the
|
||||
* function's pg_proc entry without changing its OID.
|
||||
************************************************************/
|
||||
uptodate = (prodesc->fn_xmin == procTup->t_data->t_xmin &&
|
||||
prodesc->fn_cmin == procTup->t_data->t_cmin);
|
||||
uptodate = (prodesc->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) &&
|
||||
prodesc->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data));
|
||||
|
||||
if (!uptodate)
|
||||
{
|
||||
@ -586,8 +586,8 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
|
||||
elog(ERROR, "plperl: out of memory");
|
||||
MemSet(prodesc, 0, sizeof(plperl_proc_desc));
|
||||
prodesc->proname = strdup(internal_proname);
|
||||
prodesc->fn_xmin = procTup->t_data->t_xmin;
|
||||
prodesc->fn_cmin = procTup->t_data->t_cmin;
|
||||
prodesc->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data);
|
||||
prodesc->fn_cmin = HeapTupleHeaderGetCmin(procTup->t_data);
|
||||
|
||||
/************************************************************
|
||||
* Lookup the pg_language tuple by Oid
|
||||
|
@ -3,7 +3,7 @@
|
||||
* procedural language
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.41 2002/05/03 00:32:18 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.42 2002/06/15 19:54:24 momjian Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@ -188,8 +188,8 @@ plpgsql_compile(Oid fn_oid, int functype)
|
||||
|
||||
function->fn_name = strdup(NameStr(procStruct->proname));
|
||||
function->fn_oid = fn_oid;
|
||||
function->fn_xmin = procTup->t_data->t_xmin;
|
||||
function->fn_cmin = procTup->t_data->t_cmin;
|
||||
function->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data);
|
||||
function->fn_cmin = HeapTupleHeaderGetCmin(procTup->t_data);
|
||||
function->fn_functype = functype;
|
||||
|
||||
switch (functype)
|
||||
|
@ -3,7 +3,7 @@
|
||||
* procedural language
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.10 2001/10/25 05:50:20 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.11 2002/06/15 19:54:24 momjian Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@ -167,8 +167,8 @@ func_up_to_date(PLpgSQL_function * func)
|
||||
elog(ERROR, "plpgsql: cache lookup for proc %u failed",
|
||||
func->fn_oid);
|
||||
|
||||
result = (func->fn_xmin == procTup->t_data->t_xmin &&
|
||||
func->fn_cmin == procTup->t_data->t_cmin);
|
||||
result = (func->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) &&
|
||||
func->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data));
|
||||
|
||||
ReleaseSysCache(procTup);
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.17 2002/03/29 19:06:27 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.18 2002/06/15 19:54:24 momjian Exp $
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
@ -1030,8 +1030,8 @@ PLy_procedure_get(FunctionCallInfo fcinfo, bool is_trigger)
|
||||
if (proc->me != plproc)
|
||||
elog(FATAL, "plpython: Aiieee, proc->me != plproc");
|
||||
/* did we find an up-to-date cache entry? */
|
||||
if (proc->fn_xmin != procTup->t_data->t_xmin ||
|
||||
proc->fn_cmin != procTup->t_data->t_cmin)
|
||||
if (proc->fn_xmin != HeapTupleHeaderGetXmin(procTup->t_data) ||
|
||||
proc->fn_cmin != HeapTupleHeaderGetCmin(procTup->t_data))
|
||||
{
|
||||
Py_DECREF(plproc);
|
||||
proc = NULL;
|
||||
@ -1075,8 +1075,8 @@ PLy_procedure_create(FunctionCallInfo fcinfo, bool is_trigger,
|
||||
proc = PLy_malloc(sizeof(PLyProcedure));
|
||||
proc->proname = PLy_malloc(strlen(procName) + 1);
|
||||
strcpy(proc->proname, procName);
|
||||
proc->fn_xmin = procTup->t_data->t_xmin;
|
||||
proc->fn_cmin = procTup->t_data->t_cmin;
|
||||
proc->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data);
|
||||
proc->fn_cmin = HeapTupleHeaderGetCmin(procTup->t_data);
|
||||
PLy_typeinfo_init(&proc->result);
|
||||
for (i = 0; i < FUNC_MAX_ARGS; i++)
|
||||
PLy_typeinfo_init(&proc->args[i]);
|
||||
|
@ -31,7 +31,7 @@
|
||||
* ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.55 2002/05/24 21:04:34 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.56 2002/06/15 19:54:24 momjian Exp $
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
@ -987,8 +987,8 @@ compile_pltcl_function(Oid fn_oid, bool is_trigger)
|
||||
|
||||
prodesc = (pltcl_proc_desc *) Tcl_GetHashValue(hashent);
|
||||
|
||||
uptodate = (prodesc->fn_xmin == procTup->t_data->t_xmin &&
|
||||
prodesc->fn_cmin == procTup->t_data->t_cmin);
|
||||
uptodate = (prodesc->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) &&
|
||||
prodesc->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data));
|
||||
|
||||
if (!uptodate)
|
||||
{
|
||||
@ -1025,8 +1025,8 @@ compile_pltcl_function(Oid fn_oid, bool is_trigger)
|
||||
elog(ERROR, "pltcl: out of memory");
|
||||
MemSet(prodesc, 0, sizeof(pltcl_proc_desc));
|
||||
prodesc->proname = strdup(internal_proname);
|
||||
prodesc->fn_xmin = procTup->t_data->t_xmin;
|
||||
prodesc->fn_cmin = procTup->t_data->t_cmin;
|
||||
prodesc->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data);
|
||||
prodesc->fn_cmin = HeapTupleHeaderGetCmin(procTup->t_data);
|
||||
|
||||
/************************************************************
|
||||
* Lookup the pg_language tuple by Oid
|
||||
|
Loading…
x
Reference in New Issue
Block a user