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

Commit d4fc4ac

Browse files
committed
Set a snapshot before running analyze on a single table, to avoid a
crash when analyzing tables with expressional indexes. Per report from Frank van Vugt.
1 parent ec9f81b commit d4fc4ac

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/backend/postmaster/autovacuum.c

Lines changed: 9 additions & 1 deletion
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.6 2005/11/22 18:17:17 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.7 2005/11/28 13:35:09 alvherre Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -898,6 +898,14 @@ autovacuum_do_vac_analyze(List *relids, bool dovacuum, bool doanalyze,
898898
vacstmt->relation = NULL; /* all tables, or not used if relids != NIL */
899899
vacstmt->va_cols = NIL;
900900

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+
901909
vacuum(vacstmt, relids);
902910

903911
pfree(vacstmt);

0 commit comments

Comments
 (0)