Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f171307

Browse files
committed
Install a more future-proof fix for the snapshot-unset bug just found.
Per suggestion from Tom Lane.
1 parent b79cb1e commit f171307

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/backend/postmaster/autovacuum.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.7 2005/11/28 13:35:09 alvherre Exp $
13+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.8 2005/11/28 17:23:11 alvherre Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -495,6 +495,9 @@ process_whole_db(void)
495495
/* Start a transaction so our commands have one to play into. */
496496
StartTransactionCommand();
497497

498+
/* functions in indexes may want a snapshot set */
499+
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
500+
498501
dbRel = heap_open(DatabaseRelationId, AccessShareLock);
499502

500503
/* Must use a table scan, since there's no syscache for pg_database */
@@ -556,6 +559,9 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
556559
/* Start a transaction so our commands have one to play into. */
557560
StartTransactionCommand();
558561

562+
/* functions in indexes may want a snapshot set */
563+
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
564+
559565
/*
560566
* StartTransactionCommand and CommitTransactionCommand will automatically
561567
* switch to other contexts. We need this one to keep the list of
@@ -898,14 +904,6 @@ autovacuum_do_vac_analyze(List *relids, bool dovacuum, bool doanalyze,
898904
vacstmt->relation = NULL; /* all tables, or not used if relids != NIL */
899905
vacstmt->va_cols = NIL;
900906

901-
/*
902-
* Functions in indexes may want a snapshot set. Note we only need
903-
* to do this in limited cases, because it'll be done in vacuum()
904-
* otherwise.
905-
*/
906-
if (doanalyze && !dovacuum && relids != NIL)
907-
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
908-
909907
vacuum(vacstmt, relids);
910908

911909
pfree(vacstmt);

0 commit comments

Comments
 (0)