@ -83,6 +83,7 @@ static SnapshotData SecondarySnapshotData = {SNAPSHOT_MVCC};
SnapshotData CatalogSnapshotData = { SNAPSHOT_MVCC } ;
SnapshotData SnapshotSelfData = { SNAPSHOT_SELF } ;
SnapshotData SnapshotAnyData = { SNAPSHOT_ANY } ;
SnapshotData SnapshotToastData = { SNAPSHOT_TOAST } ;
/* Pointers to valid snapshots */
static Snapshot CurrentSnapshot = NULL ;
@ -119,9 +120,6 @@ typedef struct ActiveSnapshotElt
/* Top of the stack of active snapshots */
static ActiveSnapshotElt * ActiveSnapshot = NULL ;
/* Bottom of the stack of active snapshots */
static ActiveSnapshotElt * OldestActiveSnapshot = NULL ;
/*
* Currently registered Snapshots . Ordered in a heap by xmin , so that we can
* quickly find the one with lowest xmin , to advance our MyProc - > xmin .
@ -199,8 +197,6 @@ typedef struct SerializedSnapshotData
bool suboverflowed ;
bool takenDuringRecovery ;
CommandId curcid ;
TimestampTz whenTaken ;
XLogRecPtr lsn ;
} SerializedSnapshotData ;
/*
@ -313,36 +309,6 @@ GetLatestSnapshot(void)
return SecondarySnapshot ;
}
/*
* GetOldestSnapshot
*
* Get the transaction ' s oldest known snapshot , as judged by the LSN .
* Will return NULL if there are no active or registered snapshots .
*/
Snapshot
GetOldestSnapshot ( void )
{
Snapshot OldestRegisteredSnapshot = NULL ;
XLogRecPtr RegisteredLSN = InvalidXLogRecPtr ;
if ( ! pairingheap_is_empty ( & RegisteredSnapshots ) )
{
OldestRegisteredSnapshot = pairingheap_container ( SnapshotData , ph_node ,
pairingheap_first ( & RegisteredSnapshots ) ) ;
RegisteredLSN = OldestRegisteredSnapshot - > lsn ;
}
if ( OldestActiveSnapshot ! = NULL )
{
XLogRecPtr ActiveLSN = OldestActiveSnapshot - > as_snap - > lsn ;
if ( XLogRecPtrIsInvalid ( RegisteredLSN ) | | RegisteredLSN > ActiveLSN )
return OldestActiveSnapshot - > as_snap ;
}
return OldestRegisteredSnapshot ;
}
/*
* GetCatalogSnapshot
* Get a snapshot that is sufficiently up - to - date for scan of the
@ -684,8 +650,6 @@ PushActiveSnapshotWithLevel(Snapshot snapshot, int snap_level)
newactive - > as_snap - > active_count + + ;
ActiveSnapshot = newactive ;
if ( OldestActiveSnapshot = = NULL )
OldestActiveSnapshot = ActiveSnapshot ;
}
/*
@ -756,8 +720,6 @@ PopActiveSnapshot(void)
pfree ( ActiveSnapshot ) ;
ActiveSnapshot = newstack ;
if ( ActiveSnapshot = = NULL )
OldestActiveSnapshot = NULL ;
SnapshotResetXmin ( ) ;
}
@ -902,13 +864,6 @@ xmin_cmp(const pairingheap_node *a, const pairingheap_node *b, void *arg)
* dropped . For efficiency , we only consider recomputing PGPROC - > xmin when
* the active snapshot stack is empty ; this allows us not to need to track
* which active snapshot is oldest .
*
* Note : it ' s tempting to use GetOldestSnapshot ( ) here so that we can include
* active snapshots in the calculation . However , that compares by LSN not
* xmin so it ' s not entirely clear that it ' s the same thing . Also , we ' d be
* critically dependent on the assumption that the bottommost active snapshot
* stack entry has the oldest xmin . ( Current uses of GetOldestSnapshot ( ) are
* not actually critical , but this would be . )
*/
static void
SnapshotResetXmin ( void )
@ -980,8 +935,6 @@ AtSubAbort_Snapshot(int level)
pfree ( ActiveSnapshot ) ;
ActiveSnapshot = next ;
if ( ActiveSnapshot = = NULL )
OldestActiveSnapshot = NULL ;
}
SnapshotResetXmin ( ) ;
@ -1065,7 +1018,6 @@ AtEOXact_Snapshot(bool isCommit, bool resetXmin)
* it ' ll go away with TopTransactionContext .
*/
ActiveSnapshot = NULL ;
OldestActiveSnapshot = NULL ;
pairingheap_reset ( & RegisteredSnapshots ) ;
CurrentSnapshot = NULL ;
@ -1727,8 +1679,6 @@ SerializeSnapshot(Snapshot snapshot, char *start_address)
serialized_snapshot . suboverflowed = snapshot - > suboverflowed ;
serialized_snapshot . takenDuringRecovery = snapshot - > takenDuringRecovery ;
serialized_snapshot . curcid = snapshot - > curcid ;
serialized_snapshot . whenTaken = snapshot - > whenTaken ;
serialized_snapshot . lsn = snapshot - > lsn ;
/*
* Ignore the SubXID array if it has overflowed , unless the snapshot was
@ -1801,8 +1751,6 @@ RestoreSnapshot(char *start_address)
snapshot - > suboverflowed = serialized_snapshot . suboverflowed ;
snapshot - > takenDuringRecovery = serialized_snapshot . takenDuringRecovery ;
snapshot - > curcid = serialized_snapshot . curcid ;
snapshot - > whenTaken = serialized_snapshot . whenTaken ;
snapshot - > lsn = serialized_snapshot . lsn ;
snapshot - > snapXactCompletionCount = 0 ;
/* Copy XIDs, if present. */