]> granicus.if.org Git - postgresql/commitdiff
Set a snapshot before running analyze on a single table, to avoid a
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 28 Nov 2005 13:34:10 +0000 (13:34 +0000)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 28 Nov 2005 13:34:10 +0000 (13:34 +0000)
crash when analyzing tables with expressional indexes.

src/backend/postmaster/autovacuum.c

index ba9b87ed6093f5d93841df18e155110d75fd1e24..73fea4aef4aab7f78bf133a0121edefdec6464aa 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.5.2.1 2005/11/22 18:23:15 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.5.2.2 2005/11/28 13:34:10 alvherre Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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);