@@ -83,6 +83,7 @@ static SnapshotData SecondarySnapshotData = {SNAPSHOT_MVCC};
8383SnapshotData CatalogSnapshotData = {SNAPSHOT_MVCC };
8484SnapshotData SnapshotSelfData = {SNAPSHOT_SELF };
8585SnapshotData SnapshotAnyData = {SNAPSHOT_ANY };
86+ SnapshotData SnapshotToastData = {SNAPSHOT_TOAST };
8687
8788/* Pointers to valid snapshots */
8889static Snapshot CurrentSnapshot = NULL ;
@@ -119,9 +120,6 @@ typedef struct ActiveSnapshotElt
119120/* Top of the stack of active snapshots */
120121static ActiveSnapshotElt * ActiveSnapshot = NULL ;
121122
122- /* Bottom of the stack of active snapshots */
123- static ActiveSnapshotElt * OldestActiveSnapshot = NULL ;
124-
125123/*
126124 * Currently registered Snapshots. Ordered in a heap by xmin, so that we can
127125 * quickly find the one with lowest xmin, to advance our MyProc->xmin.
@@ -199,8 +197,6 @@ typedef struct SerializedSnapshotData
199197bool suboverflowed ;
200198bool takenDuringRecovery ;
201199CommandId curcid ;
202- TimestampTz whenTaken ;
203- XLogRecPtr lsn ;
204200}SerializedSnapshotData ;
205201
206202/*
@@ -313,36 +309,6 @@ GetLatestSnapshot(void)
313309return SecondarySnapshot ;
314310}
315311
316- /*
317- * GetOldestSnapshot
318- *
319- *Get the transaction's oldest known snapshot, as judged by the LSN.
320- *Will return NULL if there are no active or registered snapshots.
321- */
322- Snapshot
323- GetOldestSnapshot (void )
324- {
325- Snapshot OldestRegisteredSnapshot = NULL ;
326- XLogRecPtr RegisteredLSN = InvalidXLogRecPtr ;
327-
328- if (!pairingheap_is_empty (& RegisteredSnapshots ))
329- {
330- OldestRegisteredSnapshot = pairingheap_container (SnapshotData ,ph_node ,
331- pairingheap_first (& RegisteredSnapshots ));
332- RegisteredLSN = OldestRegisteredSnapshot -> lsn ;
333- }
334-
335- if (OldestActiveSnapshot != NULL )
336- {
337- XLogRecPtr ActiveLSN = OldestActiveSnapshot -> as_snap -> lsn ;
338-
339- if (XLogRecPtrIsInvalid (RegisteredLSN )|| RegisteredLSN > ActiveLSN )
340- return OldestActiveSnapshot -> as_snap ;
341- }
342-
343- return OldestRegisteredSnapshot ;
344- }
345-
346312/*
347313 * GetCatalogSnapshot
348314 *Get a snapshot that is sufficiently up-to-date for scan of the
@@ -684,8 +650,6 @@ PushActiveSnapshotWithLevel(Snapshot snapshot, int snap_level)
684650newactive -> as_snap -> active_count ++ ;
685651
686652ActiveSnapshot = newactive ;
687- if (OldestActiveSnapshot == NULL )
688- OldestActiveSnapshot = ActiveSnapshot ;
689653}
690654
691655/*
@@ -756,8 +720,6 @@ PopActiveSnapshot(void)
756720
757721pfree (ActiveSnapshot );
758722ActiveSnapshot = newstack ;
759- if (ActiveSnapshot == NULL )
760- OldestActiveSnapshot = NULL ;
761723
762724SnapshotResetXmin ();
763725}
@@ -902,13 +864,6 @@ xmin_cmp(const pairingheap_node *a, const pairingheap_node *b, void *arg)
902864 * dropped. For efficiency, we only consider recomputing PGPROC->xmin when
903865 * the active snapshot stack is empty; this allows us not to need to track
904866 * which active snapshot is oldest.
905- *
906- * Note: it's tempting to use GetOldestSnapshot() here so that we can include
907- * active snapshots in the calculation. However, that compares by LSN not
908- * xmin so it's not entirely clear that it's the same thing. Also, we'd be
909- * critically dependent on the assumption that the bottommost active snapshot
910- * stack entry has the oldest xmin. (Current uses of GetOldestSnapshot() are
911- * not actually critical, but this would be.)
912867 */
913868static void
914869SnapshotResetXmin (void )
@@ -980,8 +935,6 @@ AtSubAbort_Snapshot(int level)
980935pfree (ActiveSnapshot );
981936
982937ActiveSnapshot = next ;
983- if (ActiveSnapshot == NULL )
984- OldestActiveSnapshot = NULL ;
985938}
986939
987940SnapshotResetXmin ();
@@ -1065,7 +1018,6 @@ AtEOXact_Snapshot(bool isCommit, bool resetXmin)
10651018 * it'll go away with TopTransactionContext.
10661019 */
10671020ActiveSnapshot = NULL ;
1068- OldestActiveSnapshot = NULL ;
10691021pairingheap_reset (& RegisteredSnapshots );
10701022
10711023CurrentSnapshot = NULL ;
@@ -1727,8 +1679,6 @@ SerializeSnapshot(Snapshot snapshot, char *start_address)
17271679serialized_snapshot .suboverflowed = snapshot -> suboverflowed ;
17281680serialized_snapshot .takenDuringRecovery = snapshot -> takenDuringRecovery ;
17291681serialized_snapshot .curcid = snapshot -> curcid ;
1730- serialized_snapshot .whenTaken = snapshot -> whenTaken ;
1731- serialized_snapshot .lsn = snapshot -> lsn ;
17321682
17331683/*
17341684 * Ignore the SubXID array if it has overflowed, unless the snapshot was
@@ -1801,8 +1751,6 @@ RestoreSnapshot(char *start_address)
18011751snapshot -> suboverflowed = serialized_snapshot .suboverflowed ;
18021752snapshot -> takenDuringRecovery = serialized_snapshot .takenDuringRecovery ;
18031753snapshot -> curcid = serialized_snapshot .curcid ;
1804- snapshot -> whenTaken = serialized_snapshot .whenTaken ;
1805- snapshot -> lsn = serialized_snapshot .lsn ;
18061754snapshot -> snapXactCompletionCount = 0 ;
18071755
18081756/* Copy XIDs, if present. */