mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Good Bye, Time Travel!
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.27 1997/09/24 17:44:24 thomas Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.28 1997/11/02 15:24:09 vadim Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The old interface functions have been converted to macros
|
||||
@@ -115,7 +115,7 @@ DataFill(char *data,
|
||||
TupleDesc tupleDesc,
|
||||
Datum value[],
|
||||
char nulls[],
|
||||
char *infomask,
|
||||
uint16 *infomask,
|
||||
bits8 *bit)
|
||||
{
|
||||
bits8 *bitP = 0;
|
||||
@@ -246,11 +246,6 @@ heap_attisnull(HeapTuple tup, int attnum)
|
||||
case MinCommandIdAttributeNumber:
|
||||
case MaxTransactionIdAttributeNumber:
|
||||
case MaxCommandIdAttributeNumber:
|
||||
case ChainItemPointerAttributeNumber:
|
||||
case AnchorItemPointerAttributeNumber:
|
||||
case MinAbsoluteTimeAttributeNumber:
|
||||
case MaxAbsoluteTimeAttributeNumber:
|
||||
case VersionTypeAttributeNumber:
|
||||
break;
|
||||
|
||||
case 0:
|
||||
@@ -293,18 +288,6 @@ heap_sysattrlen(AttrNumber attno)
|
||||
return sizeof f->t_xmax;
|
||||
case MaxCommandIdAttributeNumber:
|
||||
return sizeof f->t_cmax;
|
||||
case ChainItemPointerAttributeNumber:
|
||||
return sizeof f->t_chain;
|
||||
case MinAbsoluteTimeAttributeNumber:
|
||||
return sizeof f->t_tmin;
|
||||
case MaxAbsoluteTimeAttributeNumber:
|
||||
return sizeof f->t_tmax;
|
||||
case VersionTypeAttributeNumber:
|
||||
return sizeof f->t_vtype;
|
||||
|
||||
case AnchorItemPointerAttributeNumber:
|
||||
elog(WARN, "heap_sysattrlen: field t_anchor does not exist!");
|
||||
return 0;
|
||||
|
||||
default:
|
||||
elog(WARN, "sysattrlen: System attribute number %d unknown.", attno);
|
||||
@@ -343,21 +326,6 @@ heap_sysattrbyval(AttrNumber attno)
|
||||
case MaxCommandIdAttributeNumber:
|
||||
byval = true;
|
||||
break;
|
||||
case ChainItemPointerAttributeNumber:
|
||||
byval = false;
|
||||
break;
|
||||
case AnchorItemPointerAttributeNumber:
|
||||
byval = false;
|
||||
break;
|
||||
case MinAbsoluteTimeAttributeNumber:
|
||||
byval = true;
|
||||
break;
|
||||
case MaxAbsoluteTimeAttributeNumber:
|
||||
byval = true;
|
||||
break;
|
||||
case VersionTypeAttributeNumber:
|
||||
byval = true;
|
||||
break;
|
||||
default:
|
||||
byval = true;
|
||||
elog(WARN, "sysattrbyval: System attribute number %d unknown.",
|
||||
@@ -377,7 +345,7 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
|
||||
{
|
||||
switch (attnum)
|
||||
{
|
||||
case SelfItemPointerAttributeNumber:
|
||||
case SelfItemPointerAttributeNumber:
|
||||
return ((Datum) &tup->t_ctid);
|
||||
case ObjectIdAttributeNumber:
|
||||
return ((Datum) (long) tup->t_oid);
|
||||
@@ -389,38 +357,6 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
|
||||
return ((Datum) (long) tup->t_xmax);
|
||||
case MaxCommandIdAttributeNumber:
|
||||
return ((Datum) (long) tup->t_cmax);
|
||||
case ChainItemPointerAttributeNumber:
|
||||
return ((Datum) &tup->t_chain);
|
||||
case AnchorItemPointerAttributeNumber:
|
||||
elog(WARN, "heap_getsysattr: t_anchor does not exist!");
|
||||
break;
|
||||
|
||||
/*
|
||||
* For tmin and tmax, we need to do some extra work. These
|
||||
* don't get filled in until the vacuum cleaner runs (or we
|
||||
* manage to flush a page after setting the value correctly
|
||||
* below). If the vacuum cleaner hasn't run yet, then the
|
||||
* times stored in the tuple are wrong, and we need to look up
|
||||
* the commit time of the transaction. We cache this value in
|
||||
* the tuple to avoid doing the work more than once.
|
||||
*/
|
||||
|
||||
case MinAbsoluteTimeAttributeNumber:
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(tup->t_tmin) &&
|
||||
TransactionIdDidCommit(tup->t_xmin))
|
||||
tup->t_tmin = TransactionIdGetCommitTime(tup->t_xmin);
|
||||
return ((Datum) (long) tup->t_tmin);
|
||||
case MaxAbsoluteTimeAttributeNumber:
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyReal(tup->t_tmax))
|
||||
{
|
||||
if (TransactionIdDidCommit(tup->t_xmax))
|
||||
tup->t_tmax = TransactionIdGetCommitTime(tup->t_xmax);
|
||||
else
|
||||
tup->t_tmax = CURRENT_ABSTIME;
|
||||
}
|
||||
return ((Datum) (long) tup->t_tmax);
|
||||
case VersionTypeAttributeNumber:
|
||||
return ((Datum) (long) tup->t_vtype);
|
||||
default:
|
||||
elog(WARN, "heap_getsysattr: undefined attnum %d", attnum);
|
||||
}
|
||||
@@ -858,8 +794,6 @@ heap_formtuple(TupleDesc tupleDescriptor,
|
||||
tuple->t_len = len;
|
||||
tuple->t_natts = numberOfAttributes;
|
||||
tuple->t_hoff = hoff;
|
||||
tuple->t_tmin = INVALID_ABSTIME;
|
||||
tuple->t_tmax = CURRENT_ABSTIME;
|
||||
|
||||
DataFill((char *) tuple + tuple->t_hoff,
|
||||
tupleDescriptor,
|
||||
@@ -868,6 +802,8 @@ heap_formtuple(TupleDesc tupleDescriptor,
|
||||
&tuple->t_infomask,
|
||||
(hasnull ? tuple->t_bits : NULL));
|
||||
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID;
|
||||
|
||||
return (tuple);
|
||||
}
|
||||
|
||||
@@ -970,9 +906,9 @@ heap_modifytuple(HeapTuple tuple,
|
||||
* ----------------
|
||||
*/
|
||||
infomask = newTuple->t_infomask;
|
||||
memmove((char *) &newTuple->t_ctid, /* XXX */
|
||||
(char *) &tuple->t_ctid,
|
||||
((char *) &tuple->t_hoff - (char *) &tuple->t_ctid)); /* XXX */
|
||||
memmove((char *) &newTuple->t_oid, /* XXX */
|
||||
(char *) &tuple->t_oid,
|
||||
((char *) &tuple->t_hoff - (char *) &tuple->t_oid)); /* XXX */
|
||||
newTuple->t_infomask = infomask;
|
||||
newTuple->t_natts = numberOfAttributes; /* fix t_natts just in
|
||||
* case */
|
||||
@@ -1013,10 +949,11 @@ heap_addheader(uint32 natts, /* max domain index */
|
||||
tup = (HeapTuple) tp;
|
||||
MemSet((char *) tup, 0, len);
|
||||
|
||||
tup->t_len = (short) len; /* XXX */
|
||||
tup->t_len = len;
|
||||
tp += tup->t_hoff = hoff;
|
||||
tup->t_natts = natts;
|
||||
tup->t_infomask = 0;
|
||||
tup->t_infomask |= HEAP_XMAX_INVALID;
|
||||
|
||||
memmove(tp, structure, structlen);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.19 1997/09/18 20:19:37 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.20 1997/11/02 15:24:11 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -52,7 +52,7 @@ index_formtuple(TupleDesc tupleDescriptor,
|
||||
int i;
|
||||
unsigned short infomask = 0;
|
||||
bool hasnull = false;
|
||||
char tupmask = 0;
|
||||
uint16 tupmask = 0;
|
||||
int numberOfAttributes = tupleDescriptor->natts;
|
||||
|
||||
if (numberOfAttributes > MaxIndexAttributeNumber)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.20 1997/09/18 14:19:30 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.21 1997/11/02 15:24:26 vadim Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -1174,8 +1174,8 @@ heap_insert(Relation relation, HeapTuple tup)
|
||||
TransactionIdStore(GetCurrentTransactionId(), &(tup->t_xmin));
|
||||
tup->t_cmin = GetCurrentCommandId();
|
||||
StoreInvalidTransactionId(&(tup->t_xmax));
|
||||
tup->t_tmin = INVALID_ABSTIME;
|
||||
tup->t_tmax = CURRENT_ABSTIME;
|
||||
tup->t_infomask &= ~(HEAP_XACT_MASK);
|
||||
tup->t_infomask |= HEAP_XMAX_INVALID;
|
||||
|
||||
doinsert(relation, tup);
|
||||
|
||||
@@ -1281,7 +1281,7 @@ heap_delete(Relation relation, ItemPointer tid)
|
||||
*/
|
||||
TransactionIdStore(GetCurrentTransactionId(), &(tp->t_xmax));
|
||||
tp->t_cmax = GetCurrentCommandId();
|
||||
ItemPointerSetInvalid(&tp->t_chain);
|
||||
tp->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
|
||||
|
||||
/* ----------------
|
||||
* invalidate caches
|
||||
@@ -1410,9 +1410,8 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
|
||||
TransactionIdStore(GetCurrentTransactionId(), &(tup->t_xmin));
|
||||
tup->t_cmin = GetCurrentCommandId();
|
||||
StoreInvalidTransactionId(&(tup->t_xmax));
|
||||
tup->t_tmin = INVALID_ABSTIME;
|
||||
tup->t_tmax = CURRENT_ABSTIME;
|
||||
ItemPointerSetInvalid(&tup->t_chain);
|
||||
tup->t_infomask &= ~(HEAP_XACT_MASK);
|
||||
tup->t_infomask |= HEAP_XMAX_INVALID;
|
||||
|
||||
/* ----------------
|
||||
* insert new item
|
||||
@@ -1438,7 +1437,7 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
|
||||
*/
|
||||
TransactionIdStore(GetCurrentTransactionId(), &(tp->t_xmax));
|
||||
tp->t_cmax = GetCurrentCommandId();
|
||||
tp->t_chain = tup->t_ctid;
|
||||
tp->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
|
||||
|
||||
/* ----------------
|
||||
* invalidate caches
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.13 1997/09/08 21:41:42 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.14 1997/11/02 15:24:42 vadim Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file contains the high level access-method interface to the
|
||||
@@ -41,17 +41,14 @@ TransactionLogUpdate(TransactionId transactionId,
|
||||
*/
|
||||
|
||||
Relation LogRelation = (Relation) NULL;
|
||||
Relation TimeRelation = (Relation) NULL;
|
||||
Relation VariableRelation = (Relation) NULL;
|
||||
|
||||
/* ----------------
|
||||
* global variables holding cached transaction id's and statuses.
|
||||
* ----------------
|
||||
*/
|
||||
TransactionId cachedGetCommitTimeXid;
|
||||
AbsoluteTime cachedGetCommitTime;
|
||||
TransactionId cachedTestXid;
|
||||
XidStatus cachedTestXidStatus;
|
||||
TransactionId cachedTestXid;
|
||||
XidStatus cachedTestXidStatus;
|
||||
|
||||
/* ----------------
|
||||
* transaction system constants
|
||||
@@ -118,7 +115,7 @@ SetRecoveryCheckingEnabled(bool state)
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* postgres log/time access method interface
|
||||
* postgres log access method interface
|
||||
*
|
||||
* TransactionLogTest
|
||||
* TransactionLogUpdate
|
||||
@@ -204,7 +201,6 @@ TransactionLogUpdate(TransactionId transactionId, /* trans id to update */
|
||||
{
|
||||
BlockNumber blockNumber;
|
||||
bool fail = false; /* success/failure */
|
||||
AbsoluteTime currentTime; /* time of this transaction */
|
||||
|
||||
/* ----------------
|
||||
* during initialization we don't record any updates.
|
||||
@@ -213,12 +209,6 @@ TransactionLogUpdate(TransactionId transactionId, /* trans id to update */
|
||||
if (!RelationIsValid(LogRelation))
|
||||
return;
|
||||
|
||||
/* ----------------
|
||||
* get the transaction commit time
|
||||
* ----------------
|
||||
*/
|
||||
currentTime = getSystemTime();
|
||||
|
||||
/* ----------------
|
||||
* update the log relation
|
||||
* ----------------
|
||||
@@ -234,91 +224,12 @@ TransactionLogUpdate(TransactionId transactionId, /* trans id to update */
|
||||
* update (invalidate) our single item TransactionLogTest cache.
|
||||
* ----------------
|
||||
*/
|
||||
TransactionIdStore(transactionId, &cachedTestXid);
|
||||
cachedTestXidStatus = status;
|
||||
|
||||
/* ----------------
|
||||
* now we update the time relation, if necessary
|
||||
* (we only record commit times)
|
||||
* ----------------
|
||||
*/
|
||||
if (RelationIsValid(TimeRelation) && status == XID_COMMIT)
|
||||
if (status != XID_COMMIT)
|
||||
{
|
||||
TransComputeBlockNumber(TimeRelation, transactionId, &blockNumber);
|
||||
TransBlockNumberSetCommitTime(TimeRelation,
|
||||
blockNumber,
|
||||
transactionId,
|
||||
currentTime,
|
||||
&fail);
|
||||
/* ----------------
|
||||
* update (invalidate) our single item GetCommitTime cache.
|
||||
* ----------------
|
||||
*/
|
||||
TransactionIdStore(transactionId, &cachedGetCommitTimeXid);
|
||||
cachedGetCommitTime = currentTime;
|
||||
TransactionIdStore(transactionId, &cachedTestXid);
|
||||
cachedTestXidStatus = status;
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* now we update the "last committed transaction" field
|
||||
* in the variable relation if we are recording a commit.
|
||||
* ----------------
|
||||
*/
|
||||
if (RelationIsValid(VariableRelation) && status == XID_COMMIT)
|
||||
UpdateLastCommittedXid(transactionId);
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* TransactionIdGetCommitTime
|
||||
* --------------------------------
|
||||
*/
|
||||
|
||||
AbsoluteTime /* commit time of transaction id */
|
||||
TransactionIdGetCommitTime(TransactionId transactionId) /* transaction id to
|
||||
* test */
|
||||
{
|
||||
BlockNumber blockNumber;
|
||||
AbsoluteTime commitTime; /* commit time */
|
||||
bool fail = false; /* success/failure */
|
||||
|
||||
/* ----------------
|
||||
* return invalid if we aren't running yet...
|
||||
* ----------------
|
||||
*/
|
||||
if (!RelationIsValid(TimeRelation))
|
||||
return INVALID_ABSTIME;
|
||||
|
||||
/* ----------------
|
||||
* before going to the buffer manager, check our single
|
||||
* item cache to see if we didn't just get the commit time
|
||||
* a moment ago.
|
||||
* ----------------
|
||||
*/
|
||||
if (TransactionIdEquals(transactionId, cachedGetCommitTimeXid))
|
||||
return cachedGetCommitTime;
|
||||
|
||||
/* ----------------
|
||||
* compute the item pointer corresponding to the
|
||||
* page containing our transaction commit time
|
||||
* ----------------
|
||||
*/
|
||||
TransComputeBlockNumber(TimeRelation, transactionId, &blockNumber);
|
||||
commitTime = TransBlockNumberGetCommitTime(TimeRelation,
|
||||
blockNumber,
|
||||
transactionId,
|
||||
&fail);
|
||||
|
||||
/* ----------------
|
||||
* update our cache and return the transaction commit time
|
||||
* ----------------
|
||||
*/
|
||||
if (!fail)
|
||||
{
|
||||
TransactionIdStore(transactionId, &cachedGetCommitTimeXid);
|
||||
cachedGetCommitTime = commitTime;
|
||||
return commitTime;
|
||||
}
|
||||
else
|
||||
return INVALID_ABSTIME;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
@@ -472,7 +383,6 @@ void
|
||||
InitializeTransactionLog(void)
|
||||
{
|
||||
Relation logRelation;
|
||||
Relation timeRelation;
|
||||
MemoryContext oldContext;
|
||||
|
||||
/* ----------------
|
||||
@@ -503,20 +413,17 @@ InitializeTransactionLog(void)
|
||||
* ----------------
|
||||
*/
|
||||
logRelation = heap_openr(LogRelationName);
|
||||
timeRelation = heap_openr(TimeRelationName);
|
||||
VariableRelation = heap_openr(VariableRelationName);
|
||||
/* ----------------
|
||||
* XXX TransactionLogUpdate requires that LogRelation
|
||||
* and TimeRelation are valid so we temporarily set
|
||||
* them so we can initialize things properly.
|
||||
* This could be done cleaner.
|
||||
* is valid so we temporarily set it so we can initialize
|
||||
* things properly. This could be done cleaner.
|
||||
* ----------------
|
||||
*/
|
||||
LogRelation = logRelation;
|
||||
TimeRelation = timeRelation;
|
||||
|
||||
/* ----------------
|
||||
* if we have a virgin database, we initialize the log and time
|
||||
* if we have a virgin database, we initialize the log
|
||||
* relation by committing the AmiTransactionId (id 512) and we
|
||||
* initialize the variable relation by setting the next available
|
||||
* transaction id to FirstTransactionId (id 514). OID initialization
|
||||
@@ -529,10 +436,12 @@ InitializeTransactionLog(void)
|
||||
|
||||
/* ----------------
|
||||
* SOMEDAY initialize the information stored in
|
||||
* the headers of the log/time/variable relations.
|
||||
* the headers of the log/variable relations.
|
||||
* ----------------
|
||||
*/
|
||||
TransactionLogUpdate(AmiTransactionId, XID_COMMIT);
|
||||
TransactionIdStore(AmiTransactionId, &cachedTestXid);
|
||||
cachedTestXidStatus = XID_COMMIT;
|
||||
VariableRelationPutNextXid(FirstTransactionId);
|
||||
|
||||
}
|
||||
@@ -547,7 +456,6 @@ InitializeTransactionLog(void)
|
||||
TransRecover(logRelation);
|
||||
}
|
||||
LogRelation = (Relation) NULL;
|
||||
TimeRelation = (Relation) NULL;
|
||||
SpinRelease(OidGenLockId);
|
||||
|
||||
/* ----------------
|
||||
@@ -561,7 +469,6 @@ InitializeTransactionLog(void)
|
||||
* ----------------
|
||||
*/
|
||||
LogRelation = logRelation;
|
||||
TimeRelation = timeRelation;
|
||||
|
||||
/* ----------------
|
||||
* restore the memory context to the previous context
|
||||
@@ -651,15 +558,7 @@ TransactionIdCommit(TransactionId transactionId)
|
||||
if (AMI_OVERRIDE)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Within TransactionLogUpdate we call UpdateLastCommited() which
|
||||
* assumes we have exclusive access to pg_variable. Therefore we need
|
||||
* to get exclusive access before calling TransactionLogUpdate. -mer
|
||||
* 18 Aug 1992
|
||||
*/
|
||||
SpinAcquire(OidGenLockId);
|
||||
TransactionLogUpdate(transactionId, XID_COMMIT);
|
||||
SpinRelease(OidGenLockId);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.13 1997/09/08 21:41:46 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.14 1997/11/02 15:24:44 vadim Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file contains support functions for the high
|
||||
@@ -23,16 +23,10 @@
|
||||
#include <access/xact.h>
|
||||
#include <storage/lmgr.h>
|
||||
|
||||
static AbsoluteTime
|
||||
TransBlockGetCommitTime(Block tblock,
|
||||
TransactionId transactionId);
|
||||
static XidStatus
|
||||
TransBlockGetXidStatus(Block tblock,
|
||||
TransactionId transactionId);
|
||||
static void
|
||||
TransBlockSetCommitTime(Block tblock,
|
||||
TransactionId transactionId, AbsoluteTime commitTime);
|
||||
static void
|
||||
TransBlockSetXidStatus(Block tblock,
|
||||
TransactionId transactionId, XidStatus xstatus);
|
||||
|
||||
@@ -73,8 +67,6 @@ TransComputeBlockNumber(Relation relation, /* relation to test */
|
||||
*/
|
||||
if (relation == LogRelation)
|
||||
itemsPerBlock = TP_NumXidStatusPerBlock;
|
||||
else if (relation == TimeRelation)
|
||||
itemsPerBlock = TP_NumTimePerBlock;
|
||||
else
|
||||
elog(WARN, "TransComputeBlockNumber: unknown relation");
|
||||
|
||||
@@ -197,15 +189,6 @@ TransBlockGetXidStatus(Block tblock,
|
||||
bits8 bit2;
|
||||
BitIndex offset;
|
||||
|
||||
/* ----------------
|
||||
* sanity check
|
||||
* ----------------
|
||||
*/
|
||||
if (tblock == NULL)
|
||||
{
|
||||
return XID_INVALID;
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* calculate the index into the transaction data where
|
||||
* our transaction status is located
|
||||
@@ -248,13 +231,6 @@ TransBlockSetXidStatus(Block tblock,
|
||||
Index index;
|
||||
BitIndex offset;
|
||||
|
||||
/* ----------------
|
||||
* sanity check
|
||||
* ----------------
|
||||
*/
|
||||
if (tblock == NULL)
|
||||
return;
|
||||
|
||||
/* ----------------
|
||||
* calculate the index into the transaction data where
|
||||
* we sould store our transaction status.
|
||||
@@ -295,90 +271,6 @@ TransBlockSetXidStatus(Block tblock,
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* TransBlockGetCommitTime
|
||||
*
|
||||
* This returns the transaction commit time for the
|
||||
* specified transaction id in the trans block.
|
||||
* --------------------------------
|
||||
*/
|
||||
static AbsoluteTime
|
||||
TransBlockGetCommitTime(Block tblock,
|
||||
TransactionId transactionId)
|
||||
{
|
||||
Index index;
|
||||
AbsoluteTime *timeArray;
|
||||
|
||||
/* ----------------
|
||||
* sanity check
|
||||
* ----------------
|
||||
*/
|
||||
if (tblock == NULL)
|
||||
return INVALID_ABSTIME;
|
||||
|
||||
/* ----------------
|
||||
* calculate the index into the transaction data where
|
||||
* our transaction commit time is located
|
||||
*
|
||||
* XXX this will be replaced soon when we move to the
|
||||
* new transaction id scheme -cim 3/23/90
|
||||
*
|
||||
* The new scheme is here. -mer 5/24/92
|
||||
* ----------------
|
||||
*/
|
||||
index = transactionId % TP_NumTimePerBlock;
|
||||
|
||||
/* ----------------
|
||||
* return the commit time to the caller
|
||||
* ----------------
|
||||
*/
|
||||
timeArray = (AbsoluteTime *) tblock;
|
||||
return (AbsoluteTime)
|
||||
timeArray[index];
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* TransBlockSetCommitTime
|
||||
*
|
||||
* This sets the commit time of the specified transaction
|
||||
* --------------------------------
|
||||
*/
|
||||
static void
|
||||
TransBlockSetCommitTime(Block tblock,
|
||||
TransactionId transactionId,
|
||||
AbsoluteTime commitTime)
|
||||
{
|
||||
Index index;
|
||||
AbsoluteTime *timeArray;
|
||||
|
||||
/* ----------------
|
||||
* sanity check
|
||||
* ----------------
|
||||
*/
|
||||
if (tblock == NULL)
|
||||
return;
|
||||
|
||||
|
||||
/* ----------------
|
||||
* calculate the index into the transaction data where
|
||||
* we sould store our transaction status.
|
||||
*
|
||||
* XXX this will be replaced soon when we move to the
|
||||
* new transaction id scheme -cim 3/23/90
|
||||
*
|
||||
* The new scheme is here. -mer 5/24/92
|
||||
* ----------------
|
||||
*/
|
||||
index = transactionId % TP_NumTimePerBlock;
|
||||
|
||||
/* ----------------
|
||||
* store the transaction commit time at the specified index
|
||||
* ----------------
|
||||
*/
|
||||
timeArray = (AbsoluteTime *) tblock;
|
||||
timeArray[index] = commitTime;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* transam i/o support routines
|
||||
* ----------------------------------------------------------------
|
||||
@@ -494,121 +386,6 @@ TransBlockNumberSetXidStatus(Relation relation,
|
||||
RelationUnsetLockForWrite(relation);
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* TransBlockNumberGetCommitTime
|
||||
* --------------------------------
|
||||
*/
|
||||
AbsoluteTime
|
||||
TransBlockNumberGetCommitTime(Relation relation,
|
||||
BlockNumber blockNumber,
|
||||
TransactionId xid,
|
||||
bool *failP)
|
||||
{
|
||||
Buffer buffer; /* buffer associated with block */
|
||||
Block block; /* block containing commit time */
|
||||
bool localfail; /* bool used if failP = NULL */
|
||||
AbsoluteTime xtime; /* commit time */
|
||||
|
||||
/* ----------------
|
||||
* SOMEDAY place a read lock on the time relation
|
||||
*
|
||||
* That someday is today 5 Aug. 1991 -mer
|
||||
* ----------------
|
||||
*/
|
||||
RelationSetLockForRead(relation);
|
||||
|
||||
/* ----------------
|
||||
* get the block containing the transaction information
|
||||
* ----------------
|
||||
*/
|
||||
buffer = ReadBuffer(relation, blockNumber);
|
||||
block = BufferGetBlock(buffer);
|
||||
|
||||
/* ----------------
|
||||
* get the commit time from the block
|
||||
* note, for now we always return false in failP.
|
||||
* ----------------
|
||||
*/
|
||||
if (failP == NULL)
|
||||
failP = &localfail;
|
||||
(*failP) = false;
|
||||
|
||||
xtime = TransBlockGetCommitTime(block, xid);
|
||||
|
||||
/* ----------------
|
||||
* release the buffer and return the commit time
|
||||
* ----------------
|
||||
*/
|
||||
ReleaseBuffer(buffer);
|
||||
|
||||
/* ----------------
|
||||
* SOMEDAY release our lock on the time relation
|
||||
* ----------------
|
||||
*/
|
||||
RelationUnsetLockForRead(relation);
|
||||
|
||||
if ((*failP) == false)
|
||||
return xtime;
|
||||
else
|
||||
return INVALID_ABSTIME;
|
||||
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* TransBlockNumberSetCommitTime
|
||||
* --------------------------------
|
||||
*/
|
||||
void
|
||||
TransBlockNumberSetCommitTime(Relation relation,
|
||||
BlockNumber blockNumber,
|
||||
TransactionId xid,
|
||||
AbsoluteTime xtime,
|
||||
bool *failP)
|
||||
{
|
||||
Buffer buffer; /* buffer associated with block */
|
||||
Block block; /* block containing commit time */
|
||||
bool localfail; /* bool used if failP = NULL */
|
||||
|
||||
/* ----------------
|
||||
* SOMEDAY gain exclusive access to the time relation
|
||||
*
|
||||
* That someday is today 5 Aug. 1991 -mer
|
||||
* ----------------
|
||||
*/
|
||||
RelationSetLockForWrite(relation);
|
||||
|
||||
/* ----------------
|
||||
* get the block containing our commit time
|
||||
* ----------------
|
||||
*/
|
||||
buffer = ReadBuffer(relation, blockNumber);
|
||||
block = BufferGetBlock(buffer);
|
||||
|
||||
/* ----------------
|
||||
* attempt to update the commit time of the transaction on the block.
|
||||
* if we are successful, write the block. otherwise release the buffer.
|
||||
* note, for now we always return false in failP.
|
||||
* ----------------
|
||||
*/
|
||||
if (failP == NULL)
|
||||
failP = &localfail;
|
||||
(*failP) = false;
|
||||
|
||||
TransBlockSetCommitTime(block, xid, xtime);
|
||||
|
||||
if ((*failP) == false)
|
||||
WriteBuffer(buffer);
|
||||
else
|
||||
ReleaseBuffer(buffer);
|
||||
|
||||
/* ----------------
|
||||
* SOMEDAY release our lock on the time relation
|
||||
* ----------------
|
||||
*/
|
||||
RelationUnsetLockForWrite(relation);
|
||||
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* TransGetLastRecordedTransaction
|
||||
* --------------------------------
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.12 1997/09/08 21:41:49 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.13 1997/11/02 15:24:45 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -23,9 +23,7 @@
|
||||
static void GetNewObjectIdBlock(Oid *oid_return, int oid_block_size);
|
||||
static void VariableRelationGetNextOid(Oid *oid_return);
|
||||
static void VariableRelationGetNextXid(TransactionId *xidP);
|
||||
static void VariableRelationPutLastXid(TransactionId xid);
|
||||
static void VariableRelationPutNextOid(Oid *oidP);
|
||||
static void VariableRelationGetLastXid(TransactionId *xidP);
|
||||
|
||||
/* ---------------------
|
||||
* spin lock for oid generation
|
||||
@@ -80,49 +78,6 @@ VariableRelationGetNextXid(TransactionId *xidP)
|
||||
ReleaseBuffer(buf);
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* VariableRelationGetLastXid
|
||||
* --------------------------------
|
||||
*/
|
||||
static void
|
||||
VariableRelationGetLastXid(TransactionId *xidP)
|
||||
{
|
||||
Buffer buf;
|
||||
VariableRelationContents var;
|
||||
|
||||
/* ----------------
|
||||
* We assume that a spinlock has been acquire to guarantee
|
||||
* exclusive access to the variable relation.
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
/* ----------------
|
||||
* do nothing before things are initialized
|
||||
* ----------------
|
||||
*/
|
||||
if (!RelationIsValid(VariableRelation))
|
||||
return;
|
||||
|
||||
/* ----------------
|
||||
* read the variable page, get the the lastXid field and
|
||||
* release the buffer
|
||||
* ----------------
|
||||
*/
|
||||
buf = ReadBuffer(VariableRelation, 0);
|
||||
|
||||
if (!BufferIsValid(buf))
|
||||
{
|
||||
SpinRelease(OidGenLockId);
|
||||
elog(WARN, "VariableRelationGetNextXid: ReadBuffer failed");
|
||||
}
|
||||
|
||||
var = (VariableRelationContents) BufferGetBlock(buf);
|
||||
|
||||
TransactionIdStore(var->lastXidData, xidP);
|
||||
|
||||
ReleaseBuffer(buf);
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* VariableRelationPutNextXid
|
||||
* --------------------------------
|
||||
@@ -169,49 +124,6 @@ VariableRelationPutNextXid(TransactionId xid)
|
||||
SetBufferWriteMode(flushmode);
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* VariableRelationPutLastXid
|
||||
* --------------------------------
|
||||
*/
|
||||
static void
|
||||
VariableRelationPutLastXid(TransactionId xid)
|
||||
{
|
||||
Buffer buf;
|
||||
VariableRelationContents var;
|
||||
|
||||
/* ----------------
|
||||
* We assume that a spinlock has been acquire to guarantee
|
||||
* exclusive access to the variable relation.
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
/* ----------------
|
||||
* do nothing before things are initialized
|
||||
* ----------------
|
||||
*/
|
||||
if (!RelationIsValid(VariableRelation))
|
||||
return;
|
||||
|
||||
/* ----------------
|
||||
* read the variable page, update the lastXid field and
|
||||
* force the page back out to disk.
|
||||
* ----------------
|
||||
*/
|
||||
buf = ReadBuffer(VariableRelation, 0);
|
||||
|
||||
if (!BufferIsValid(buf))
|
||||
{
|
||||
SpinRelease(OidGenLockId);
|
||||
elog(WARN, "VariableRelationPutLastXid: ReadBuffer failed");
|
||||
}
|
||||
|
||||
var = (VariableRelationContents) BufferGetBlock(buf);
|
||||
|
||||
TransactionIdStore(xid, &(var->lastXidData));
|
||||
|
||||
WriteBuffer(buf);
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* VariableRelationGetNextOid
|
||||
* --------------------------------
|
||||
@@ -449,40 +361,6 @@ GetNewTransactionId(TransactionId *xid)
|
||||
prefetched_xid_count--;
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* UpdateLastCommittedXid
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
void
|
||||
UpdateLastCommittedXid(TransactionId xid)
|
||||
{
|
||||
TransactionId lastid;
|
||||
|
||||
|
||||
/*
|
||||
* we assume that spinlock OidGenLockId has been acquired prior to
|
||||
* entering this function
|
||||
*/
|
||||
|
||||
/* ----------------
|
||||
* get the "last committed" transaction id from
|
||||
* the variable relation page.
|
||||
* ----------------
|
||||
*/
|
||||
VariableRelationGetLastXid(&lastid);
|
||||
|
||||
/* ----------------
|
||||
* if the transaction id is greater than the last committed
|
||||
* transaction then we update the last committed transaction
|
||||
* in the variable relation.
|
||||
* ----------------
|
||||
*/
|
||||
if (TransactionIdIsLessThan(lastid, xid))
|
||||
VariableRelationPutLastXid(xid);
|
||||
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* object id generation support
|
||||
* ----------------------------------------------------------------
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.16 1997/09/08 21:41:52 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.17 1997/11/02 15:24:46 vadim Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Transaction aborts can now occur two ways:
|
||||
@@ -497,7 +497,7 @@ CommandCounterIncrement()
|
||||
if (CurrentTransactionStateData.commandId == FirstCommandId)
|
||||
{
|
||||
CommandIdCounterOverflowFlag = true;
|
||||
elog(WARN, "You may only have 65535 commands per transaction");
|
||||
elog(WARN, "You may only have 2^32-1 commands per transaction");
|
||||
}
|
||||
|
||||
CurrentTransactionStateData.scanCommandId =
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.10 1997/09/08 21:41:56 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.11 1997/11/02 15:24:47 vadim Exp $
|
||||
*
|
||||
* OLD COMMENTS
|
||||
* XXX WARNING
|
||||
@@ -30,18 +30,6 @@ extern TransactionId DisabledTransactionId;
|
||||
extern TransactionId AmiTransactionId;
|
||||
extern TransactionId FirstTransactionId;
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* TransactionIdIsValid
|
||||
*
|
||||
* Macro-ize me.
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
bool
|
||||
TransactionIdIsValid(TransactionId transactionId)
|
||||
{
|
||||
return ((bool) (transactionId != NullTransactionId));
|
||||
}
|
||||
|
||||
/* XXX char16 name for catalogs */
|
||||
TransactionId
|
||||
xidin(char *representation)
|
||||
@@ -65,32 +53,6 @@ xidout(TransactionId transactionId)
|
||||
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* StoreInvalidTransactionId
|
||||
*
|
||||
* Maybe do away with Pointer types in these routines.
|
||||
* Macro-ize this one.
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
StoreInvalidTransactionId(TransactionId *destination)
|
||||
{
|
||||
*destination = NullTransactionId;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* TransactionIdStore
|
||||
*
|
||||
* Macro-ize this one.
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
TransactionIdStore(TransactionId transactionId,
|
||||
TransactionId *destination)
|
||||
{
|
||||
*destination = transactionId;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* TransactionIdEquals
|
||||
* ----------------------------------------------------------------
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# Makefile for catalog
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.2 1996/11/03 23:26:58 scrappy Exp $
|
||||
# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.3 1997/11/02 15:24:52 vadim Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -30,7 +30,7 @@ GENBKI= ./genbki.sh
|
||||
GLOBALBKI_SRCS= $(addprefix ../../include/catalog/, \
|
||||
pg_database.h pg_demon.h pg_magic.h pg_defaults.h \
|
||||
pg_variable.h pg_server.h pg_user.h pg_hosts.h \
|
||||
pg_group.h pg_log.h pg_time.h \
|
||||
pg_group.h pg_log.h \
|
||||
)
|
||||
|
||||
LOCALBKI_SRCS= $(addprefix ../../include/catalog/, \
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.29 1997/09/18 20:20:11 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.30 1997/11/02 15:24:55 vadim Exp $
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
* heap_creatr() - Create an uncataloged heap relation
|
||||
@@ -108,7 +108,7 @@ static FormData_pg_attribute a3 = {
|
||||
|
||||
static FormData_pg_attribute a4 = {
|
||||
0xffffffff, {"cmin"}, 29l, 0l, sizeof(CommandId),
|
||||
MinCommandIdAttributeNumber, 0, -1, '\001', '\0', 's', '\0', '\0'
|
||||
MinCommandIdAttributeNumber, 0, -1, '\001', '\0', 'i', '\0', '\0'
|
||||
};
|
||||
|
||||
static FormData_pg_attribute a5 = {
|
||||
@@ -118,36 +118,11 @@ static FormData_pg_attribute a5 = {
|
||||
|
||||
static FormData_pg_attribute a6 = {
|
||||
0xffffffff, {"cmax"}, 29l, 0l, sizeof(CommandId),
|
||||
MaxCommandIdAttributeNumber, 0, -1, '\001', '\0', 's', '\0', '\0'
|
||||
};
|
||||
|
||||
static FormData_pg_attribute a7 = {
|
||||
0xffffffff, {"chain"}, 27l, 0l, sizeof(ItemPointerData),
|
||||
ChainItemPointerAttributeNumber, 0, -1, '\0', '\0', 'i', '\0', '\0'
|
||||
};
|
||||
|
||||
static FormData_pg_attribute a8 = {
|
||||
0xffffffff, {"anchor"}, 27l, 0l, sizeof(ItemPointerData),
|
||||
AnchorItemPointerAttributeNumber, 0, -1, '\0', '\0', 'i', '\0', '\0'
|
||||
};
|
||||
|
||||
static FormData_pg_attribute a9 = {
|
||||
0xffffffff, {"tmin"}, 702l, 0l, sizeof(AbsoluteTime),
|
||||
MinAbsoluteTimeAttributeNumber, 0, -1, '\001', '\0', 'i', '\0', '\0'
|
||||
};
|
||||
|
||||
static FormData_pg_attribute a10 = {
|
||||
0xffffffff, {"tmax"}, 702l, 0l, sizeof(AbsoluteTime),
|
||||
MaxAbsoluteTimeAttributeNumber, 0, -1, '\001', '\0', 'i', '\0', '\0'
|
||||
};
|
||||
|
||||
static FormData_pg_attribute a11 = {
|
||||
0xffffffff, {"vtype"}, 18l, 0l, sizeof(char),
|
||||
VersionTypeAttributeNumber, 0, -1, '\001', '\0', 'c', '\0', '\0'
|
||||
MaxCommandIdAttributeNumber, 0, -1, '\001', '\0', 'i', '\0', '\0'
|
||||
};
|
||||
|
||||
static AttributeTupleForm HeapAtt[] =
|
||||
{&a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10, &a11};
|
||||
{&a1, &a2, &a3, &a4, &a5, &a6};
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* XXX END OF UGLY HARD CODED BADNESS XXX
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.24 1997/10/27 11:52:43 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.25 1997/11/02 15:25:01 vadim Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -119,14 +119,9 @@ static FormData_pg_attribute sysatts[] = {
|
||||
{0l, {"ctid"}, 27l, 0l, 6, -1, 0, -1, '\0', '\0', 'i', '\0', '\0'},
|
||||
{0l, {"oid"}, 26l, 0l, 4, -2, 0, -1, '\001', '\0', 'i', '\0', '\0'},
|
||||
{0l, {"xmin"}, 28l, 0l, 4, -3, 0, -1, '\0', '\0', 'i', '\0', '\0'},
|
||||
{0l, {"cmin"}, 29l, 0l, 2, -4, 0, -1, '\001', '\0', 's', '\0', '\0'},
|
||||
{0l, {"cmin"}, 29l, 0l, 4, -4, 0, -1, '\001', '\0', 'i', '\0', '\0'},
|
||||
{0l, {"xmax"}, 28l, 0l, 4, -5, 0, -1, '\0', '\0', 'i', '\0', '\0'},
|
||||
{0l, {"cmax"}, 29l, 0l, 2, -6, 0, -1, '\001', '\0', 's', '\0', '\0'},
|
||||
{0l, {"chain"}, 27l, 0l, 6, -7, 0, -1, '\0', '\0', 'i', '\0', '\0'},
|
||||
{0l, {"anchor"}, 27l, 0l, 6, -8, 0, -1, '\0', '\0', 'i', '\0', '\0'},
|
||||
{0l, {"tmin"}, 702l, 0l, 4, -9, 0, -1, '\001', '\0', 'i', '\0', '\0'},
|
||||
{0l, {"tmax"}, 702l, 0l, 4, -10, 0, -1, '\001', '\0', 'i', '\0', '\0'},
|
||||
{0l, {"vtype"}, 18l, 0l, 1, -11, 0, -1, '\001', '\0', 'c', '\0', '\0'},
|
||||
{0l, {"cmax"}, 29l, 0l, 4, -6, 0, -1, '\001', '\0', 'i', '\0', '\0'},
|
||||
};
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.48 1997/09/22 07:12:33 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.49 1997/11/02 15:25:07 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -742,54 +742,60 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
htup = (HeapTuple) PageGetItem(page, itemid);
|
||||
tupgone = false;
|
||||
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(htup->t_tmin) &&
|
||||
TransactionIdIsValid((TransactionId) htup->t_xmin))
|
||||
if (!(htup->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
{
|
||||
|
||||
if (TransactionIdDidAbort(htup->t_xmin))
|
||||
{
|
||||
if (htup->t_infomask & HEAP_XMIN_INVALID)
|
||||
tupgone = true;
|
||||
}
|
||||
else if (TransactionIdDidCommit(htup->t_xmin))
|
||||
{
|
||||
htup->t_tmin = TransactionIdGetCommitTime(htup->t_xmin);
|
||||
pgchanged = true;
|
||||
}
|
||||
else if (!TransactionIdIsInProgress(htup->t_xmin))
|
||||
{
|
||||
|
||||
/*
|
||||
* Not Aborted, Not Committed, Not in Progress - so it
|
||||
* from crashed process. - vadim 11/26/96
|
||||
*/
|
||||
ncrash++;
|
||||
tupgone = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(NOTICE, "Rel %s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation",
|
||||
relname, blkno, offnum, htup->t_xmin);
|
||||
do_shrinking = false;
|
||||
if (TransactionIdDidAbort(htup->t_xmin))
|
||||
tupgone = true;
|
||||
else if (TransactionIdDidCommit(htup->t_xmin))
|
||||
{
|
||||
htup->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
pgchanged = true;
|
||||
}
|
||||
else if (!TransactionIdIsInProgress(htup->t_xmin))
|
||||
{
|
||||
/*
|
||||
* Not Aborted, Not Committed, Not in Progress -
|
||||
* so it's from crashed process. - vadim 11/26/96
|
||||
*/
|
||||
ncrash++;
|
||||
tupgone = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(NOTICE, "Rel %s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation",
|
||||
relname, blkno, offnum, htup->t_xmin);
|
||||
do_shrinking = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TransactionIdIsValid((TransactionId) htup->t_xmax))
|
||||
/*
|
||||
* here we are concerned about tuples with xmin committed
|
||||
* and xmax unknown or committed
|
||||
*/
|
||||
if (htup->t_infomask & HEAP_XMIN_COMMITTED &&
|
||||
!(htup->t_infomask & HEAP_XMAX_INVALID))
|
||||
{
|
||||
if (TransactionIdDidAbort(htup->t_xmax))
|
||||
if (htup->t_infomask & HEAP_XMAX_COMMITTED)
|
||||
tupgone = true;
|
||||
else if (TransactionIdDidAbort(htup->t_xmax))
|
||||
{
|
||||
StoreInvalidTransactionId(&(htup->t_xmax));
|
||||
htup->t_infomask |= HEAP_XMAX_INVALID;
|
||||
pgchanged = true;
|
||||
}
|
||||
else if (TransactionIdDidCommit(htup->t_xmax))
|
||||
tupgone = true;
|
||||
else if (!TransactionIdIsInProgress(htup->t_xmax))
|
||||
{
|
||||
|
||||
/*
|
||||
* Not Aborted, Not Committed, Not in Progress - so it
|
||||
* from crashed process. - vadim 06/02/97
|
||||
*/
|
||||
StoreInvalidTransactionId(&(htup->t_xmax));
|
||||
htup->t_infomask |= HEAP_XMAX_INVALID;;
|
||||
pgchanged = true;
|
||||
}
|
||||
else
|
||||
@@ -800,18 +806,6 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Is it possible at all ? - vadim 11/26/96
|
||||
*/
|
||||
if (!TransactionIdIsValid((TransactionId) htup->t_xmin))
|
||||
{
|
||||
elog(NOTICE, "Rel %s: TID %u/%u: INSERT_TRANSACTION_ID IS INVALID. \
|
||||
DELETE_TRANSACTION_ID_VALID %d, TUPGONE %d.",
|
||||
relname, blkno, offnum,
|
||||
TransactionIdIsValid((TransactionId) htup->t_xmax),
|
||||
tupgone);
|
||||
}
|
||||
|
||||
/*
|
||||
* It's possibly! But from where it comes ? And should we fix
|
||||
* it ? - vadim 11/28/96
|
||||
@@ -973,7 +967,6 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
{
|
||||
TransactionId myXID;
|
||||
CommandId myCID;
|
||||
AbsoluteTime myCTM = 0;
|
||||
Buffer buf,
|
||||
ToBuf;
|
||||
int nblocks,
|
||||
@@ -1187,9 +1180,9 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
TransactionIdStore(myXID, &(newtup->t_xmin));
|
||||
newtup->t_cmin = myCID;
|
||||
StoreInvalidTransactionId(&(newtup->t_xmax));
|
||||
newtup->t_tmin = INVALID_ABSTIME;
|
||||
newtup->t_tmax = CURRENT_ABSTIME;
|
||||
ItemPointerSetInvalid(&newtup->t_chain);
|
||||
/* set xmin to unknown and xmax to invalid */
|
||||
newtup->t_infomask &= ~(HEAP_XACT_MASK);
|
||||
newtup->t_infomask |= HEAP_XMAX_INVALID;
|
||||
|
||||
/* add tuple to the page */
|
||||
newoff = PageAddItem(ToPage, (Item) newtup, tlen,
|
||||
@@ -1209,7 +1202,8 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
/* now logically delete end-tuple */
|
||||
TransactionIdStore(myXID, &(htup->t_xmax));
|
||||
htup->t_cmax = myCID;
|
||||
memmove((char *) &(htup->t_chain), (char *) &(newtup->t_ctid), sizeof(newtup->t_ctid));
|
||||
/* set xmax to unknown */
|
||||
htup->t_infomask &= ~(HEAP_XMAX_INVALID | HEAP_XMAX_COMMITTED);
|
||||
|
||||
ToVpd->vpd_nusd++;
|
||||
nmoved++;
|
||||
@@ -1278,11 +1272,10 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
FlushBufferPool(!TransactionFlushEnabled());
|
||||
TransactionIdCommit(myXID);
|
||||
FlushBufferPool(!TransactionFlushEnabled());
|
||||
myCTM = TransactionIdGetCommitTime(myXID);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean uncleaned reapped pages from Vvpl list and set commit' times
|
||||
* Clean uncleaned reapped pages from Vvpl list and set xmin committed
|
||||
* for inserted tuples
|
||||
*/
|
||||
nchkmvd = 0;
|
||||
@@ -1316,7 +1309,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
htup = (HeapTuple) PageGetItem(page, itemid);
|
||||
if (TransactionIdEquals((TransactionId) htup->t_xmin, myXID))
|
||||
{
|
||||
htup->t_tmin = myCTM;
|
||||
htup->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
ntups++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.13 1997/09/19 06:52:49 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.14 1997/11/02 15:25:11 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1470,21 +1470,8 @@ _copyRangeTblEntry(RangeTblEntry *from)
|
||||
newnode->relname = pstrdup(from->relname);
|
||||
if (from->refname)
|
||||
newnode->refname = pstrdup(from->refname);
|
||||
if (from->timeRange)
|
||||
{
|
||||
newnode->timeRange = makeNode(TimeRange);
|
||||
if (from->timeRange->startDate)
|
||||
newnode->timeRange->startDate = pstrdup(from->timeRange->startDate);
|
||||
else
|
||||
newnode->timeRange->startDate = NULL;
|
||||
if (from->timeRange->endDate)
|
||||
newnode->timeRange->endDate = pstrdup(from->timeRange->endDate);
|
||||
else
|
||||
newnode->timeRange->endDate = NULL;
|
||||
newnode->timeQual = makeTimeRange(newnode->timeRange->startDate,
|
||||
newnode->timeRange->endDate,
|
||||
((newnode->timeRange->endDate == NULL) ? 0 : 1));
|
||||
}
|
||||
newnode->timeRange = NULL;
|
||||
newnode->timeQual = NULL;
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.28 1997/09/18 20:21:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.29 1997/11/02 15:25:19 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -75,21 +75,6 @@ struct
|
||||
{
|
||||
"cmax", MaxCommandIdAttributeNumber
|
||||
},
|
||||
{
|
||||
"chain", ChainItemPointerAttributeNumber
|
||||
},
|
||||
{
|
||||
"anchor", AnchorItemPointerAttributeNumber
|
||||
},
|
||||
{
|
||||
"tmin", MinAbsoluteTimeAttributeNumber
|
||||
},
|
||||
{
|
||||
"tmax", MaxAbsoluteTimeAttributeNumber
|
||||
},
|
||||
{
|
||||
"vtype", VersionTypeAttributeNumber
|
||||
}
|
||||
};
|
||||
|
||||
#define SPECIALS (sizeof(special_attr)/sizeof(*special_attr))
|
||||
@@ -101,11 +86,6 @@ static char *attnum_type[SPECIALS] = {
|
||||
"cid",
|
||||
"xid",
|
||||
"cid",
|
||||
"tid",
|
||||
"tid",
|
||||
"abstime",
|
||||
"abstime",
|
||||
"char"
|
||||
};
|
||||
|
||||
#define MAXFARGS 8 /* max # args to a c or postquel function */
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.61 1997/10/31 00:50:39 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.62 1997/11/02 15:25:26 vadim Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -2391,12 +2391,14 @@ time_range: '[' opt_range_start ',' opt_range_end ']'
|
||||
$$ = makeNode(TimeRange);
|
||||
$$->startDate = $2;
|
||||
$$->endDate = $4;
|
||||
elog (WARN, "parser: TimeRange is not supported");
|
||||
}
|
||||
| '[' date ']'
|
||||
{
|
||||
$$ = makeNode(TimeRange);
|
||||
$$->startDate = $2;
|
||||
$$->endDate = NULL;
|
||||
elog (WARN, "parser: TimeRange is not supported");
|
||||
}
|
||||
;
|
||||
|
||||
@@ -3387,7 +3389,6 @@ relation_name: SpecialRuleRelation
|
||||
/* disallow refs to magic system tables */
|
||||
if (strcmp(LogRelationName, $1) == 0
|
||||
|| strcmp(VariableRelationName, $1) == 0
|
||||
|| strcmp(TimeRelationName, $1) == 0
|
||||
|| strcmp(MagicRelationName, $1) == 0)
|
||||
elog(WARN,"%s cannot be accessed by users",$1);
|
||||
else
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.21 1997/09/08 21:46:08 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.22 1997/11/02 15:25:30 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -243,67 +243,6 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
|
||||
return (te_head);
|
||||
}
|
||||
|
||||
TimeQual
|
||||
makeTimeRange(char *datestring1,
|
||||
char *datestring2,
|
||||
int timecode) /* 0 = snapshot , 1 = timerange */
|
||||
{
|
||||
TimeQual qual = NULL;
|
||||
AbsoluteTime t1,
|
||||
t2;
|
||||
|
||||
switch (timecode)
|
||||
{
|
||||
case 0:
|
||||
if (datestring1 == NULL)
|
||||
{
|
||||
elog(WARN, "MakeTimeRange: bad snapshot arg");
|
||||
}
|
||||
t1 = nabstimein(datestring1);
|
||||
if (!AbsoluteTimeIsValid(t1))
|
||||
{
|
||||
elog(WARN, "bad snapshot time: \"%s\"",
|
||||
datestring1);
|
||||
}
|
||||
qual = TimeFormSnapshotTimeQual(t1);
|
||||
break;
|
||||
case 1:
|
||||
if (datestring1 == NULL)
|
||||
{
|
||||
t1 = NOSTART_ABSTIME;
|
||||
}
|
||||
else
|
||||
{
|
||||
t1 = nabstimein(datestring1);
|
||||
if (!AbsoluteTimeIsValid(t1))
|
||||
{
|
||||
elog(WARN,
|
||||
"bad range start time: \"%s\"",
|
||||
datestring1);
|
||||
}
|
||||
}
|
||||
if (datestring2 == NULL)
|
||||
{
|
||||
t2 = NOEND_ABSTIME;
|
||||
}
|
||||
else
|
||||
{
|
||||
t2 = nabstimein(datestring2);
|
||||
if (!AbsoluteTimeIsValid(t2))
|
||||
{
|
||||
elog(WARN,
|
||||
"bad range end time: \"%s\"",
|
||||
datestring2);
|
||||
}
|
||||
}
|
||||
qual = TimeFormRangedTimeQual(t1, t2);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "MakeTimeRange: internal parser error");
|
||||
}
|
||||
return qual;
|
||||
}
|
||||
|
||||
static void
|
||||
disallow_setop(char *op, Type optype, Node *operand)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.14 1997/09/18 20:21:16 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.15 1997/11/02 15:25:36 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -70,9 +70,7 @@ extern IpcSemaphoreId WaitIOSemId;
|
||||
long *PrivateRefCount; /* also used in freelist.c */
|
||||
long *LastRefCount; /* refcounts of last ExecMain level */
|
||||
long *CommitInfoNeedsSave;/* to write buffers where we have filled
|
||||
* in */
|
||||
|
||||
/* t_tmin (or t_tmax) */
|
||||
* in t_infomask */
|
||||
|
||||
/*
|
||||
* Data Structures:
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.18 1997/09/12 04:08:15 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.19 1997/11/02 15:25:40 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "access/heapam.h"
|
||||
#include "access/relscan.h"
|
||||
#include "access/tupdesc.h"
|
||||
#include "access/transam.h"
|
||||
#include "access/xact.h"
|
||||
#include "access/nbtree.h"
|
||||
#include "access/tupdesc.h"
|
||||
@@ -791,6 +792,7 @@ inv_wrold(LargeObjectDesc *obj_desc,
|
||||
|
||||
TransactionIdStore(GetCurrentTransactionId(), &(htup->t_xmax));
|
||||
htup->t_cmax = GetCurrentCommandId();
|
||||
htup->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
|
||||
|
||||
/*
|
||||
* If we're overwriting the entire block, we're lucky. All we need to
|
||||
@@ -1005,18 +1007,14 @@ inv_newtuple(LargeObjectDesc *obj_desc,
|
||||
|
||||
ntup->t_len = tupsize;
|
||||
ItemPointerSet(&(ntup->t_ctid), BufferGetBlockNumber(buffer), off);
|
||||
ItemPointerSetInvalid(&(ntup->t_chain));
|
||||
LastOidProcessed = ntup->t_oid = newoid();
|
||||
TransactionIdStore(GetCurrentTransactionId(), &(ntup->t_xmin));
|
||||
ntup->t_cmin = GetCurrentCommandId();
|
||||
StoreInvalidTransactionId(&(ntup->t_xmax));
|
||||
ntup->t_cmax = 0;
|
||||
ntup->t_tmin = INVALID_ABSTIME;
|
||||
ntup->t_tmax = CURRENT_ABSTIME;
|
||||
ntup->t_infomask = HEAP_XMAX_INVALID;
|
||||
ntup->t_natts = 2;
|
||||
ntup->t_hoff = hoff;
|
||||
ntup->t_vtype = 0;
|
||||
ntup->t_infomask = 0x0;
|
||||
|
||||
/* if a NULL is passed in, avoid the calculations below */
|
||||
if (dbuf == NULL)
|
||||
@@ -1132,22 +1130,20 @@ DumpPage(Page page, int blkno)
|
||||
printf("\n\t:ctid=%s:oid=%d",
|
||||
ItemPointerFormExternal(&tup->t_ctid),
|
||||
tup->t_oid);
|
||||
printf(":natts=%d:thoff=%d:vtype=`%c' (0x%02x):",
|
||||
printf(":natts=%d:thoff=%d:",
|
||||
tup->t_natts,
|
||||
tup->t_hoff, tup->t_vtype, tup->t_vtype);
|
||||
tup->t_hoff);
|
||||
|
||||
printf("\n\t:tmin=%d:cmin=%u:",
|
||||
tup->t_tmin, tup->t_cmin);
|
||||
printf("\n\t:cmin=%u:",
|
||||
tup->t_cmin);
|
||||
|
||||
printf("xmin=%u:", tup->t_xmin);
|
||||
|
||||
printf("\n\t:tmax=%d:cmax=%u:",
|
||||
tup->t_tmax, tup->t_cmax);
|
||||
printf("\n\t:cmax=%u:",
|
||||
tup->t_cmax);
|
||||
|
||||
printf("xmax=%u:", tup->t_xmax);
|
||||
printf("xmax=%u:\n", tup->t_xmax);
|
||||
|
||||
printf("\n\t:chain=%s:\n",
|
||||
ItemPointerFormExternal(&tup->t_chain));
|
||||
} else
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.50 1997/10/25 01:10:16 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.51 1997/11/02 15:25:45 vadim Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@@ -495,54 +495,6 @@ pg_plan(char *query_string, /* string to execute */
|
||||
|
||||
querytree_list = new_list;
|
||||
|
||||
/* ----------------
|
||||
* Fix time range quals
|
||||
* this _must_ go here, because it must take place after rewrites
|
||||
* ( if they take place ) so that time quals are usable by the executor
|
||||
*
|
||||
* Also, need to frob the range table entries here to plan union
|
||||
* queries for archived relations.
|
||||
* ----------------
|
||||
*/
|
||||
for (i = 0; i < querytree_list->len; i++)
|
||||
{
|
||||
List *l;
|
||||
List *rt = NULL;
|
||||
|
||||
querytree = querytree_list->qtrees[i];
|
||||
|
||||
/* ----------------
|
||||
* utilities don't have time ranges
|
||||
* ----------------
|
||||
*/
|
||||
if (querytree->commandType == CMD_UTILITY)
|
||||
continue;
|
||||
|
||||
rt = querytree->rtable;
|
||||
|
||||
foreach(l, rt)
|
||||
{
|
||||
RangeTblEntry *rte = lfirst(l);
|
||||
TimeRange *timequal = rte->timeRange;
|
||||
|
||||
if (timequal)
|
||||
{
|
||||
int timecode = (rte->timeRange->endDate == NULL) ? 0 : 1;
|
||||
|
||||
rte->timeQual = makeTimeRange(rte->timeRange->startDate,
|
||||
rte->timeRange->endDate,
|
||||
timecode);
|
||||
}
|
||||
else
|
||||
{
|
||||
rte->timeQual = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* check for archived relations */
|
||||
plan_archive(rt);
|
||||
}
|
||||
|
||||
if (DebugPrintRewrittenParsetree == true)
|
||||
{
|
||||
printf("\n---- \tafter rewriting:\n");
|
||||
@@ -1391,7 +1343,7 @@ PostgresMain(int argc, char *argv[])
|
||||
if (IsUnderPostmaster == false)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface");
|
||||
puts("$Revision: 1.50 $ $Date: 1997/10/25 01:10:16 $");
|
||||
puts("$Revision: 1.51 $ $Date: 1997/11/02 15:25:45 $");
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.13 1997/10/25 05:12:38 thomas Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.14 1997/11/02 15:25:57 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -81,12 +81,7 @@ cidout(int32 c)
|
||||
char *result;
|
||||
CommandId c2;
|
||||
|
||||
/*
|
||||
* cid is a number between 0 .. 2^16-1, therefore we need at most 6
|
||||
* chars for the string (5 digits + '\0') NOTE: print it as an
|
||||
* UNSIGNED int!
|
||||
*/
|
||||
result = palloc(6);
|
||||
result = palloc(12);
|
||||
c2 = (CommandId) c;
|
||||
sprintf(result, "%u", (unsigned) (c2));
|
||||
return (result);
|
||||
|
||||
5
src/backend/utils/cache/relcache.c
vendored
5
src/backend/utils/cache/relcache.c
vendored
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.26 1997/10/25 05:38:52 thomas Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.27 1997/11/02 15:26:06 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -80,7 +80,6 @@
|
||||
|
||||
#include "catalog/pg_variable.h"
|
||||
#include "catalog/pg_log.h"
|
||||
#include "catalog/pg_time.h"
|
||||
#include "catalog/pg_attrdef.h"
|
||||
#include "catalog/pg_relcheck.h"
|
||||
#include "catalog/indexing.h"
|
||||
@@ -118,7 +117,6 @@ FormData_pg_attribute Desc_pg_proc[Natts_pg_proc] = {Schema_pg_proc};
|
||||
FormData_pg_attribute Desc_pg_type[Natts_pg_type] = {Schema_pg_type};
|
||||
FormData_pg_attribute Desc_pg_variable[Natts_pg_variable] = {Schema_pg_variable};
|
||||
FormData_pg_attribute Desc_pg_log[Natts_pg_log] = {Schema_pg_log};
|
||||
FormData_pg_attribute Desc_pg_time[Natts_pg_time] = {Schema_pg_time};
|
||||
|
||||
/* ----------------
|
||||
* global variables
|
||||
@@ -1679,7 +1677,6 @@ RelationInitialize(void)
|
||||
formrdesc(TypeRelationName, Natts_pg_type, Desc_pg_type);
|
||||
formrdesc(VariableRelationName, Natts_pg_variable, Desc_pg_variable);
|
||||
formrdesc(LogRelationName, Natts_pg_log, Desc_pg_log);
|
||||
formrdesc(TimeRelationName, Natts_pg_time, Desc_pg_time);
|
||||
|
||||
/*
|
||||
* If this isn't initdb time, then we want to initialize some index
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.14 1997/09/18 14:33:46 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.15 1997/11/02 15:26:12 vadim Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Globals used all over the place should be declared here and not
|
||||
@@ -114,7 +114,6 @@ char *SharedSystemRelationNames[] = {
|
||||
LogRelationName,
|
||||
MagicRelationName,
|
||||
ServerRelationName,
|
||||
TimeRelationName,
|
||||
UserRelationName,
|
||||
VariableRelationName,
|
||||
0
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* tqual.c--
|
||||
* POSTGRES time qualification code.
|
||||
* POSTGRES "time" qualification code.
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.8 1997/09/12 04:08:57 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.9 1997/11/02 15:26:17 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -22,50 +22,11 @@
|
||||
#include "access/transam.h"
|
||||
#include "utils/elog.h"
|
||||
#include "utils/palloc.h"
|
||||
#include "utils/nabstime.h"
|
||||
|
||||
#include "utils/tqual.h"
|
||||
|
||||
static AbsoluteTime TimeQualGetEndTime(TimeQual qual);
|
||||
static AbsoluteTime TimeQualGetSnapshotTime(TimeQual qual);
|
||||
static AbsoluteTime TimeQualGetStartTime(TimeQual qual);
|
||||
static bool TimeQualIncludesNow(TimeQual qual);
|
||||
static bool TimeQualIndicatesDisableValidityChecking(TimeQual qual);
|
||||
static bool TimeQualIsLegal(TimeQual qual);
|
||||
#ifndef NO_ASSERT_CHECKING
|
||||
static bool TimeQualIsRanged(TimeQual qual);
|
||||
static bool TimeQualIsValid(TimeQual qual);
|
||||
#endif
|
||||
static bool TimeQualIsSnapshot(TimeQual qual);
|
||||
|
||||
/*
|
||||
* TimeQualMode --
|
||||
* Mode indicator for treatment of time qualifications.
|
||||
*/
|
||||
typedef uint16 TimeQualMode;
|
||||
|
||||
#define TimeQualAt 0x1
|
||||
#define TimeQualNewer 0x2
|
||||
#define TimeQualOlder 0x4
|
||||
#define TimeQualAll 0x8
|
||||
|
||||
#define TimeQualMask 0xf
|
||||
|
||||
#define TimeQualEvery 0x0
|
||||
#define TimeQualRange (TimeQualNewer | TimeQualOlder)
|
||||
#define TimeQualAllAt (TimeQualAt | TimeQualAll)
|
||||
|
||||
typedef struct TimeQualData
|
||||
{
|
||||
AbsoluteTime start;
|
||||
AbsoluteTime end;
|
||||
TimeQualMode mode;
|
||||
} TimeQualData;
|
||||
|
||||
typedef TimeQualData *InternalTimeQual;
|
||||
|
||||
static TimeQualData SelfTimeQualData;
|
||||
TimeQual SelfTimeQual = (Pointer) &SelfTimeQualData;
|
||||
static int4 SelfTimeQualData;
|
||||
TimeQual SelfTimeQual = (TimeQual) &SelfTimeQualData;
|
||||
|
||||
extern bool PostgresIsInitialized;
|
||||
|
||||
@@ -119,363 +80,6 @@ heapisoverride()
|
||||
|
||||
static bool HeapTupleSatisfiesItself(HeapTuple tuple);
|
||||
static bool HeapTupleSatisfiesNow(HeapTuple tuple);
|
||||
static bool
|
||||
HeapTupleSatisfiesSnapshotInternalTimeQual(HeapTuple tuple,
|
||||
InternalTimeQual qual);
|
||||
static bool
|
||||
HeapTupleSatisfiesUpperBoundedInternalTimeQual(HeapTuple tuple,
|
||||
InternalTimeQual qual);
|
||||
static bool
|
||||
HeapTupleSatisfiesUpperUnboundedInternalTimeQual(HeapTuple tuple,
|
||||
InternalTimeQual qual);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* TimeQualIsValid --
|
||||
* True iff time qualification is valid.
|
||||
*/
|
||||
#ifndef NO_ASSERT_CHECKING
|
||||
static bool
|
||||
TimeQualIsValid(TimeQual qual)
|
||||
{
|
||||
bool hasStartTime;
|
||||
|
||||
if (!PointerIsValid(qual) || qual == SelfTimeQual)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (((InternalTimeQual) qual)->mode & ~TimeQualMask)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (((InternalTimeQual) qual)->mode & TimeQualAt)
|
||||
{
|
||||
return (AbsoluteTimeIsBackwardCompatiblyValid(((InternalTimeQual) qual)->start));
|
||||
}
|
||||
|
||||
hasStartTime = false;
|
||||
|
||||
if (((InternalTimeQual) qual)->mode & TimeQualNewer)
|
||||
{
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(((InternalTimeQual) qual)->start))
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
hasStartTime = true;
|
||||
}
|
||||
|
||||
if (((InternalTimeQual) qual)->mode & TimeQualOlder)
|
||||
{
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(((InternalTimeQual) qual)->end))
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
if (hasStartTime)
|
||||
{
|
||||
return ((bool) !AbsoluteTimeIsBefore(
|
||||
((InternalTimeQual) qual)->end,
|
||||
((InternalTimeQual) qual)->start));
|
||||
}
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TimeQualIsLegal --
|
||||
* True iff time qualification is legal.
|
||||
* I.e., true iff time qualification does not intersects the future,
|
||||
* relative to the transaction start time.
|
||||
*
|
||||
* Note:
|
||||
* Assumes time qualification is valid.
|
||||
*/
|
||||
static bool
|
||||
TimeQualIsLegal(TimeQual qual)
|
||||
{
|
||||
Assert(TimeQualIsValid(qual));
|
||||
|
||||
if (qual == NowTimeQual || qual == SelfTimeQual)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
/* TimeQualAt */
|
||||
if (((InternalTimeQual) qual)->mode & TimeQualAt)
|
||||
{
|
||||
AbsoluteTime a,
|
||||
b;
|
||||
|
||||
a = ((InternalTimeQual) qual)->start;
|
||||
b = GetCurrentTransactionStartTime();
|
||||
|
||||
if (AbsoluteTimeIsAfter(a, b))
|
||||
return (false);
|
||||
else
|
||||
return (true);
|
||||
}
|
||||
|
||||
/* TimeQualOlder or TimeQualRange */
|
||||
if (((InternalTimeQual) qual)->mode & TimeQualOlder)
|
||||
{
|
||||
AbsoluteTime a,
|
||||
b;
|
||||
|
||||
a = ((InternalTimeQual) qual)->end;
|
||||
b = GetCurrentTransactionStartTime();
|
||||
|
||||
if (AbsoluteTimeIsAfter(a, b))
|
||||
return (false);
|
||||
else
|
||||
return (true);
|
||||
}
|
||||
|
||||
/* TimeQualNewer */
|
||||
if (((InternalTimeQual) qual)->mode & TimeQualNewer)
|
||||
{
|
||||
AbsoluteTime a,
|
||||
b;
|
||||
|
||||
a = ((InternalTimeQual) qual)->start;
|
||||
b = GetCurrentTransactionStartTime();
|
||||
|
||||
if (AbsoluteTimeIsAfter(a, b))
|
||||
return (false);
|
||||
else
|
||||
return (true);
|
||||
}
|
||||
|
||||
/* TimeQualEvery */
|
||||
return (true);
|
||||
}
|
||||
|
||||
/*
|
||||
* TimeQualIncludesNow --
|
||||
* True iff time qualification includes "now."
|
||||
*
|
||||
* Note:
|
||||
* Assumes time qualification is valid.
|
||||
*/
|
||||
static bool
|
||||
TimeQualIncludesNow(TimeQual qual)
|
||||
{
|
||||
Assert(TimeQualIsValid(qual));
|
||||
|
||||
if (qual == NowTimeQual || qual == SelfTimeQual)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (((InternalTimeQual) qual)->mode & TimeQualAt)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
if (((InternalTimeQual) qual)->mode & TimeQualOlder &&
|
||||
!AbsoluteTimeIsAfter(
|
||||
((InternalTimeQual) qual)->end,
|
||||
GetCurrentTransactionStartTime()))
|
||||
{
|
||||
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/*
|
||||
* TimeQualIncludesPast --
|
||||
* True iff time qualification includes some time in the past.
|
||||
*
|
||||
* Note:
|
||||
* Assumes time qualification is valid.
|
||||
* XXX may not be needed?
|
||||
*/
|
||||
#ifdef NOT_USED
|
||||
bool
|
||||
TimeQualIncludesPast(TimeQual qual)
|
||||
{
|
||||
Assert(TimeQualIsValid(qual));
|
||||
|
||||
if (qual == NowTimeQual || qual == SelfTimeQual)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
/* otherwise, must check archive (setting locks as appropriate) */
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TimeQualIsSnapshot --
|
||||
* True iff time qualification is a snapshot qualification.
|
||||
*
|
||||
* Note:
|
||||
* Assumes time qualification is valid.
|
||||
*/
|
||||
static bool
|
||||
TimeQualIsSnapshot(TimeQual qual)
|
||||
{
|
||||
Assert(TimeQualIsValid(qual));
|
||||
|
||||
if (qual == NowTimeQual || qual == SelfTimeQual)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
return ((bool) !!(((InternalTimeQual) qual)->mode & TimeQualAt));
|
||||
}
|
||||
|
||||
/*
|
||||
* TimeQualIsRanged --
|
||||
* True iff time qualification is a ranged qualification.
|
||||
*
|
||||
* Note:
|
||||
* Assumes time qualification is valid.
|
||||
*/
|
||||
#ifndef NO_ASSERT_CHECKING
|
||||
static bool
|
||||
TimeQualIsRanged(TimeQual qual)
|
||||
{
|
||||
Assert(TimeQualIsValid(qual));
|
||||
|
||||
if (qual == NowTimeQual || qual == SelfTimeQual)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
return ((bool) !(((InternalTimeQual) qual)->mode & TimeQualAt));
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TimeQualIndicatesDisableValidityChecking --
|
||||
* True iff time qualification indicates validity checking should be
|
||||
* disabled.
|
||||
*
|
||||
* Note:
|
||||
* XXX This should not be implemented since this does not make sense.
|
||||
*/
|
||||
static bool
|
||||
TimeQualIndicatesDisableValidityChecking(TimeQual qual)
|
||||
{
|
||||
Assert(TimeQualIsValid(qual));
|
||||
|
||||
if (qual == NowTimeQual || qual == SelfTimeQual)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (((InternalTimeQual) qual)->mode & TimeQualAll)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
/*
|
||||
* TimeQualGetSnapshotTime --
|
||||
* Returns time for a snapshot time qual.
|
||||
*
|
||||
* Note:
|
||||
* Assumes time qual is valid snapshot time qual.
|
||||
*/
|
||||
static AbsoluteTime
|
||||
TimeQualGetSnapshotTime(TimeQual qual)
|
||||
{
|
||||
Assert(TimeQualIsSnapshot(qual));
|
||||
|
||||
return (((InternalTimeQual) qual)->start);
|
||||
}
|
||||
|
||||
/*
|
||||
* TimeQualGetStartTime --
|
||||
* Returns start time for a ranged time qual.
|
||||
*
|
||||
* Note:
|
||||
* Assumes time qual is valid ranged time qual.
|
||||
*/
|
||||
static AbsoluteTime
|
||||
TimeQualGetStartTime(TimeQual qual)
|
||||
{
|
||||
Assert(TimeQualIsRanged(qual));
|
||||
|
||||
return (((InternalTimeQual) qual)->start);
|
||||
}
|
||||
|
||||
/*
|
||||
* TimeQualGetEndTime --
|
||||
* Returns end time for a ranged time qual.
|
||||
*
|
||||
* Note:
|
||||
* Assumes time qual is valid ranged time qual.
|
||||
*/
|
||||
static AbsoluteTime
|
||||
TimeQualGetEndTime(TimeQual qual)
|
||||
{
|
||||
Assert(TimeQualIsRanged(qual));
|
||||
|
||||
return (((InternalTimeQual) qual)->end);
|
||||
}
|
||||
|
||||
/*
|
||||
* TimeFormSnapshotTimeQual --
|
||||
* Returns snapshot time qual for a time.
|
||||
*
|
||||
* Note:
|
||||
* Assumes time is valid.
|
||||
*/
|
||||
TimeQual
|
||||
TimeFormSnapshotTimeQual(AbsoluteTime time)
|
||||
{
|
||||
InternalTimeQual qual;
|
||||
|
||||
Assert(AbsoluteTimeIsBackwardCompatiblyValid(time));
|
||||
|
||||
qual = (InternalTimeQual) palloc(sizeof *qual);
|
||||
|
||||
qual->start = time;
|
||||
qual->end = INVALID_ABSTIME;
|
||||
qual->mode = TimeQualAt;
|
||||
|
||||
return ((TimeQual) qual);
|
||||
}
|
||||
|
||||
/*
|
||||
* TimeFormRangedTimeQual --
|
||||
* Returns ranged time qual for a pair of times.
|
||||
*
|
||||
* Note:
|
||||
* If start time is invalid, it is regarded as the epoch.
|
||||
* If end time is invalid, it is regarded as "now."
|
||||
* Assumes start time is before (or the same as) end time.
|
||||
*/
|
||||
TimeQual
|
||||
TimeFormRangedTimeQual(AbsoluteTime startTime,
|
||||
AbsoluteTime endTime)
|
||||
{
|
||||
InternalTimeQual qual;
|
||||
|
||||
qual = (InternalTimeQual) palloc(sizeof *qual);
|
||||
|
||||
qual->start = startTime;
|
||||
qual->end = endTime;
|
||||
qual->mode = TimeQualEvery;
|
||||
|
||||
if (AbsoluteTimeIsBackwardCompatiblyValid(startTime))
|
||||
{
|
||||
qual->mode |= TimeQualNewer;
|
||||
}
|
||||
if (AbsoluteTimeIsBackwardCompatiblyValid(endTime))
|
||||
{
|
||||
qual->mode |= TimeQualOlder;
|
||||
}
|
||||
|
||||
return ((TimeQual) qual);
|
||||
}
|
||||
|
||||
/*
|
||||
* HeapTupleSatisfiesTimeQual --
|
||||
@@ -484,16 +88,10 @@ TimeFormRangedTimeQual(AbsoluteTime startTime,
|
||||
* Note:
|
||||
* Assumes heap tuple is valid.
|
||||
* Assumes time qual is valid.
|
||||
* XXX Many of the checks may be simplified and still remain correct.
|
||||
* XXX Partial answers to the checks may be cached in an ItemId.
|
||||
*/
|
||||
bool
|
||||
HeapTupleSatisfiesTimeQual(HeapTuple tuple, TimeQual qual)
|
||||
{
|
||||
/* extern TransactionId AmiTransactionId; */
|
||||
|
||||
Assert(HeapTupleIsValid(tuple));
|
||||
Assert(TimeQualIsValid(qual));
|
||||
|
||||
if (TransactionIdEquals(tuple->t_xmax, AmiTransactionId))
|
||||
return (false);
|
||||
@@ -508,30 +106,9 @@ HeapTupleSatisfiesTimeQual(HeapTuple tuple, TimeQual qual)
|
||||
return (HeapTupleSatisfiesNow(tuple));
|
||||
}
|
||||
|
||||
if (!TimeQualIsLegal(qual))
|
||||
{
|
||||
elog(WARN, "HeapTupleSatisfiesTimeQual: illegal time qual");
|
||||
}
|
||||
elog(WARN, "HeapTupleSatisfiesTimeQual: illegal time qual");
|
||||
|
||||
if (TimeQualIndicatesDisableValidityChecking(qual))
|
||||
{
|
||||
elog(WARN, "HeapTupleSatisfiesTimeQual: no disabled validity checking (yet)");
|
||||
}
|
||||
|
||||
if (TimeQualIsSnapshot(qual))
|
||||
{
|
||||
return (HeapTupleSatisfiesSnapshotInternalTimeQual(tuple,
|
||||
(InternalTimeQual) qual));
|
||||
}
|
||||
|
||||
if (TimeQualIncludesNow(qual))
|
||||
{
|
||||
return (HeapTupleSatisfiesUpperUnboundedInternalTimeQual(tuple,
|
||||
(InternalTimeQual) qual));
|
||||
}
|
||||
|
||||
return (HeapTupleSatisfiesUpperBoundedInternalTimeQual(tuple,
|
||||
(InternalTimeQual) qual));
|
||||
return (false);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -560,50 +137,48 @@ static bool
|
||||
HeapTupleSatisfiesItself(HeapTuple tuple)
|
||||
{
|
||||
|
||||
/*
|
||||
* XXX Several evil casts are made in this routine. Casting XID to be
|
||||
* TransactionId works only because TransactionId->data is the first
|
||||
* (and only) field of the structure.
|
||||
*/
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(tuple->t_tmin))
|
||||
if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
{
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_xmin) &&
|
||||
!TransactionIdIsValid((TransactionId) tuple->t_xmax))
|
||||
if (tuple->t_infomask & HEAP_XMIN_INVALID) /* xid invalid or aborted */
|
||||
return (false);
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId(tuple->t_xmin))
|
||||
{
|
||||
return (true);
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
|
||||
return (true);
|
||||
else
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (!TransactionIdDidCommit((TransactionId) tuple->t_xmin))
|
||||
if (!TransactionIdDidCommit(tuple->t_xmin))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmin))
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */
|
||||
return (false);
|
||||
}
|
||||
|
||||
tuple->t_tmin = TransactionIdGetCommitTime(tuple->t_xmin);
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
}
|
||||
/* the tuple was inserted validly */
|
||||
|
||||
if (AbsoluteTimeIsBackwardCompatiblyReal(tuple->t_tmax))
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (!TransactionIdIsValid((TransactionId) tuple->t_xmax))
|
||||
{
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid or aborted */
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_xmax))
|
||||
{
|
||||
if (tuple->t_infomask & HEAP_XMAX_COMMITTED)
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (!TransactionIdDidCommit((TransactionId) tuple->t_xmax))
|
||||
if (TransactionIdIsCurrentTransactionId(tuple->t_xmax))
|
||||
return (false);
|
||||
|
||||
if (!TransactionIdDidCommit(tuple->t_xmax))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmax))
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID; /* aborted */
|
||||
return (true);
|
||||
}
|
||||
|
||||
/* by here, deleting transaction has committed */
|
||||
tuple->t_tmax = TransactionIdGetCommitTime(tuple->t_xmax);
|
||||
tuple->t_infomask |= HEAP_XMAX_COMMITTED;
|
||||
|
||||
return (false);
|
||||
}
|
||||
@@ -667,295 +242,69 @@ HeapTupleSatisfiesNow(HeapTuple tuple)
|
||||
*/
|
||||
|
||||
if (!PostgresIsInitialized)
|
||||
return ((bool) (TransactionIdIsValid((TransactionId) tuple->t_xmin) &&
|
||||
!TransactionIdIsValid((TransactionId) tuple->t_xmax)));
|
||||
return ((bool) (TransactionIdIsValid(tuple->t_xmin) &&
|
||||
!TransactionIdIsValid(tuple->t_xmax)));
|
||||
|
||||
/*
|
||||
* XXX Several evil casts are made in this routine. Casting XID to be
|
||||
* TransactionId works only because TransactionId->data is the first
|
||||
* (and only) field of the structure.
|
||||
*/
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(tuple->t_tmin))
|
||||
if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
{
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_xmin)
|
||||
&& CommandIdGEScanCommandId(tuple->t_cmin))
|
||||
{
|
||||
|
||||
if (tuple->t_infomask & HEAP_XMIN_INVALID) /* xid invalid or aborted */
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_xmin)
|
||||
&& !CommandIdGEScanCommandId(tuple->t_cmin))
|
||||
if (TransactionIdIsCurrentTransactionId(tuple->t_xmin))
|
||||
{
|
||||
if (CommandIdGEScanCommandId(tuple->t_cmin))
|
||||
return (false); /* inserted after scan started */
|
||||
|
||||
if (!TransactionIdIsValid((TransactionId) tuple->t_xmax))
|
||||
{
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
|
||||
return (true);
|
||||
}
|
||||
|
||||
Assert(TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_xmax));
|
||||
Assert(TransactionIdIsCurrentTransactionId(tuple->t_xmax));
|
||||
|
||||
if (CommandIdGEScanCommandId(tuple->t_cmax))
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
return (true); /* deleted after scan started */
|
||||
else
|
||||
return (false); /* deleted before scan started */
|
||||
}
|
||||
|
||||
/*
|
||||
* this call is VERY expensive - requires a log table lookup.
|
||||
*/
|
||||
|
||||
if (!TransactionIdDidCommit((TransactionId) tuple->t_xmin))
|
||||
if (!TransactionIdDidCommit(tuple->t_xmin))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmin))
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */
|
||||
return (false);
|
||||
}
|
||||
|
||||
/*
|
||||
* the transaction has been committed--store the commit time _now_
|
||||
* instead of waiting for a vacuum so we avoid the expensive call
|
||||
* next time.
|
||||
*/
|
||||
tuple->t_tmin = TransactionIdGetCommitTime(tuple->t_xmin);
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
}
|
||||
|
||||
/* by here, the inserting transaction has committed */
|
||||
if (!TransactionIdIsValid((TransactionId) tuple->t_xmax))
|
||||
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid or aborted */
|
||||
return (true);
|
||||
|
||||
if (tuple->t_infomask & HEAP_XMAX_COMMITTED)
|
||||
return (false);
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId(tuple->t_xmax))
|
||||
{
|
||||
if (CommandIdGEScanCommandId(tuple->t_cmax))
|
||||
return (true); /* deleted after scan started */
|
||||
else
|
||||
return (false); /* deleted before scan started */
|
||||
}
|
||||
|
||||
if (!TransactionIdDidCommit(tuple->t_xmax))
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmax))
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID; /* aborted */
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_xmax))
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (AbsoluteTimeIsBackwardCompatiblyReal(tuple->t_tmax))
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (!TransactionIdDidCommit((TransactionId) tuple->t_xmax))
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
/* xmax transaction committed, but no tmax set. so set it. */
|
||||
tuple->t_tmax = TransactionIdGetCommitTime(tuple->t_xmax);
|
||||
/* xmax transaction committed */
|
||||
tuple->t_infomask |= HEAP_XMAX_COMMITTED;
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
/*
|
||||
* HeapTupleSatisfiesSnapshotInternalTimeQual --
|
||||
* True iff heap tuple is valid at the snapshot time qualification.
|
||||
*
|
||||
* Note:
|
||||
* Assumes heap tuple is valid.
|
||||
* Assumes internal time qualification is valid snapshot qualification.
|
||||
*/
|
||||
/*
|
||||
* The satisfaction of Rel[T] requires the following:
|
||||
*
|
||||
* (Xmin is committed && Tmin <= T &&
|
||||
* (Xmax is null || (Xmax is not committed && Xmax != my-transaction) ||
|
||||
* Tmax >= T))
|
||||
*/
|
||||
static bool
|
||||
HeapTupleSatisfiesSnapshotInternalTimeQual(HeapTuple tuple,
|
||||
InternalTimeQual qual)
|
||||
{
|
||||
|
||||
/*
|
||||
* XXX Several evil casts are made in this routine. Casting XID to be
|
||||
* TransactionId works only because TransactionId->data is the first
|
||||
* (and only) field of the structure.
|
||||
*/
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(tuple->t_tmin))
|
||||
{
|
||||
|
||||
if (!TransactionIdDidCommit((TransactionId) tuple->t_xmin))
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
tuple->t_tmin = TransactionIdGetCommitTime(tuple->t_xmin);
|
||||
}
|
||||
|
||||
if (AbsoluteTimeIsBefore(TimeQualGetSnapshotTime((TimeQual) qual), tuple->t_tmin))
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
/* the tuple was inserted validly before the snapshot time */
|
||||
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyReal(tuple->t_tmax))
|
||||
{
|
||||
|
||||
if (!TransactionIdIsValid((TransactionId) tuple->t_xmax) ||
|
||||
!TransactionIdDidCommit((TransactionId) tuple->t_xmax))
|
||||
{
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
tuple->t_tmax = TransactionIdGetCommitTime(tuple->t_xmax);
|
||||
}
|
||||
|
||||
return ((bool)
|
||||
AbsoluteTimeIsAfter(tuple->t_tmax,
|
||||
TimeQualGetSnapshotTime((TimeQual) qual)));
|
||||
}
|
||||
|
||||
/*
|
||||
* HeapTupleSatisfiesUpperBoundedInternalTimeQual --
|
||||
* True iff heap tuple is valid within a upper bounded time qualification.
|
||||
*
|
||||
* Note:
|
||||
* Assumes heap tuple is valid.
|
||||
* Assumes time qualification is valid ranged qualification with fixed
|
||||
* upper bound.
|
||||
*/
|
||||
/*
|
||||
* The satisfaction of [T1,T2] requires the following:
|
||||
*
|
||||
* (Xmin is committed && Tmin <= T2 &&
|
||||
* (Xmax is null || (Xmax is not committed && Xmax != my-transaction) ||
|
||||
* T1 is null || Tmax >= T1))
|
||||
*/
|
||||
static bool
|
||||
HeapTupleSatisfiesUpperBoundedInternalTimeQual(HeapTuple tuple,
|
||||
InternalTimeQual qual)
|
||||
{
|
||||
|
||||
/*
|
||||
* XXX Several evil casts are made in this routine. Casting XID to be
|
||||
* TransactionId works only because TransactionId->data is the first
|
||||
* (and only) field of the structure.
|
||||
*/
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(tuple->t_tmin))
|
||||
{
|
||||
|
||||
if (!TransactionIdDidCommit((TransactionId) tuple->t_xmin))
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
tuple->t_tmin = TransactionIdGetCommitTime(tuple->t_xmin);
|
||||
}
|
||||
|
||||
if (AbsoluteTimeIsBefore(TimeQualGetEndTime((TimeQual) qual), tuple->t_tmin))
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
/* the tuple was inserted validly before the range end */
|
||||
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(TimeQualGetStartTime((TimeQual) qual)))
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyReal(tuple->t_tmax))
|
||||
{
|
||||
|
||||
if (!TransactionIdIsValid((TransactionId) tuple->t_xmax) ||
|
||||
!TransactionIdDidCommit((TransactionId) tuple->t_xmax))
|
||||
{
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
tuple->t_tmax = TransactionIdGetCommitTime(tuple->t_xmax);
|
||||
}
|
||||
|
||||
return ((bool) AbsoluteTimeIsAfter(tuple->t_tmax,
|
||||
TimeQualGetStartTime((TimeQual) qual)));
|
||||
}
|
||||
|
||||
/*
|
||||
* HeapTupleSatisfiesUpperUnboundedInternalTimeQual --
|
||||
* True iff heap tuple is valid within a upper bounded time qualification.
|
||||
*
|
||||
* Note:
|
||||
* Assumes heap tuple is valid.
|
||||
* Assumes time qualification is valid ranged qualification with no
|
||||
* upper bound.
|
||||
*/
|
||||
/*
|
||||
* The satisfaction of [T1,] requires the following:
|
||||
*
|
||||
* ((Xmin == my-transaction && Cmin != my-command &&
|
||||
* (Xmax is null || (Xmax == my-transaction && Cmax != my-command)))
|
||||
* ||
|
||||
*
|
||||
* (Xmin is committed &&
|
||||
* (Xmax is null || (Xmax == my-transaction && Cmax == my-command) ||
|
||||
* (Xmax is not committed && Xmax != my-transaction) ||
|
||||
* T1 is null || Tmax >= T1)))
|
||||
*/
|
||||
static bool
|
||||
HeapTupleSatisfiesUpperUnboundedInternalTimeQual(HeapTuple tuple,
|
||||
InternalTimeQual qual)
|
||||
{
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(tuple->t_tmin))
|
||||
{
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_xmin) &&
|
||||
CommandIdGEScanCommandId(tuple->t_cmin))
|
||||
{
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_xmin) &&
|
||||
!CommandIdGEScanCommandId(tuple->t_cmin))
|
||||
{
|
||||
|
||||
if (!TransactionIdIsValid((TransactionId) tuple->t_xmax))
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
Assert(TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_xmax));
|
||||
|
||||
return ((bool) !CommandIdGEScanCommandId(tuple->t_cmax));
|
||||
}
|
||||
|
||||
if (!TransactionIdDidCommit((TransactionId) tuple->t_xmin))
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
tuple->t_tmin = TransactionIdGetCommitTime(tuple->t_xmin);
|
||||
}
|
||||
/* the tuple was inserted validly */
|
||||
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(TimeQualGetStartTime((TimeQual) qual)))
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (!AbsoluteTimeIsBackwardCompatiblyReal(tuple->t_tmax))
|
||||
{
|
||||
|
||||
if (!TransactionIdIsValid((TransactionId) tuple->t_xmax))
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_xmax))
|
||||
{
|
||||
return (CommandIdGEScanCommandId(tuple->t_cmin));
|
||||
/* it looks like error ^^^^ */
|
||||
}
|
||||
|
||||
if (!TransactionIdDidCommit((TransactionId) tuple->t_xmax))
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
tuple->t_tmax = TransactionIdGetCommitTime(tuple->t_xmax);
|
||||
}
|
||||
|
||||
return ((bool) AbsoluteTimeIsAfter(tuple->t_tmax,
|
||||
TimeQualGetStartTime((TimeQual) qual)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user