From: Alvaro Herrera Date: Mon, 28 Nov 2005 13:34:10 +0000 (+0000) Subject: Set a snapshot before running analyze on a single table, to avoid a X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=d748fa633508df7318c29dfbecd8a52ff823a160;p=users%2Fbernd%2Fpostgres.git Set a snapshot before running analyze on a single table, to avoid a crash when analyzing tables with expressional indexes. --- diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index cd4f274946..7969d8e98e 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -898,6 +898,14 @@ autovacuum_do_vac_analyze(List *relids, bool dovacuum, bool doanalyze, vacstmt->relation = NULL; /* all tables, or not used if relids != NIL */ vacstmt->va_cols = NIL; + /* + * Functions in indexes may want a snapshot set. Note we only need + * to do this in limited cases, because it'll be done in vacuum() + * otherwise. + */ + if (doanalyze && !dovacuum && relids != NIL) + ActiveSnapshot = CopySnapshot(GetTransactionSnapshot()); + vacuum(vacstmt, relids); pfree(vacstmt);