Index: src/backend/commands/vacuum.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/commands/vacuum.c,v
retrieving revision 1.342.2.5
diff -c -p -r1.342.2.5 vacuum.c
*** src/backend/commands/vacuum.c	11 Feb 2008 19:14:38 -0000	1.342.2.5
--- src/backend/commands/vacuum.c	11 Sep 2008 01:08:10 -0000
*************** vac_update_datfrozenxid(void)
*** 764,777 ****
  	bool		dirty = false;
  
  	/*
! 	 * Initialize the "min" calculation with RecentGlobalXmin.  Any
! 	 * not-yet-committed pg_class entries for new tables must have
! 	 * relfrozenxid at least this high, because any other open xact must have
! 	 * RecentXmin >= its PGPROC.xmin >= our RecentGlobalXmin; see
! 	 * AddNewRelationTuple().  So we cannot produce a wrong minimum by
! 	 * starting with this.
  	 */
! 	newFrozenXid = RecentGlobalXmin;
  
  	/*
  	 * We must seqscan pg_class to find the minimum Xid, because there is no
--- 764,775 ----
  	bool		dirty = false;
  
  	/*
! 	 * Initialize the "min" calculation with GetOldestXmin, which is a
! 	 * reasonable approximation to the minimum relfrozenxid for not-yet-
! 	 * committed pg_class entries for new tables; see AddNewRelationTuple().
! 	 * Se we cannot produce a wrong minimum by starting with this.
  	 */
! 	newFrozenXid = GetOldestXmin(true, true);
  
  	/*
  	 * We must seqscan pg_class to find the minimum Xid, because there is no
*************** vacuum_rel(Oid relid, VacuumStmt *vacstm
*** 965,982 ****
  	/* Begin a transaction for vacuuming this relation */
  	StartTransactionCommand();
  
! 	if (vacstmt->full)
! 	{
! 		/* functions in indexes may want a snapshot set */
! 		ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
! 	}
! 	else
  	{
  		/*
! 		 * During a lazy VACUUM we do not run any user-supplied functions, and
! 		 * so it should be safe to not create a transaction snapshot.
! 		 *
! 		 * We can furthermore set the inVacuum flag, which lets other
  		 * concurrent VACUUMs know that they can ignore this one while
  		 * determining their OldestXmin.  (The reason we don't set inVacuum
  		 * during a full VACUUM is exactly that we may have to run user-
--- 963,978 ----
  	/* Begin a transaction for vacuuming this relation */
  	StartTransactionCommand();
  
! 	/*
! 	 * Functions in indexes may want a snapshot set. Also, setting
! 	 * a snapshot ensures that RecentGlobalXmin is kept truly recent.
! 	 */
! 	ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
! 
! 	if (!vacstmt->full)
  	{
  		/*
! 		 * During a lazy VACUUM we can set the inVacuum flag, which lets other
  		 * concurrent VACUUMs know that they can ignore this one while
  		 * determining their OldestXmin.  (The reason we don't set inVacuum
  		 * during a full VACUUM is exactly that we may have to run user-
Index: src/backend/utils/init/postinit.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/init/postinit.c,v
retrieving revision 1.172
diff -c -p -r1.172 postinit.c
*** src/backend/utils/init/postinit.c	5 Nov 2006 22:42:09 -0000	1.172
--- src/backend/utils/init/postinit.c	10 Sep 2008 23:43:45 -0000
***************
*** 42,47 ****
--- 42,48 ----
  #include "utils/guc.h"
  #include "utils/portal.h"
  #include "utils/relcache.h"
+ #include "utils/tqual.h"
  #include "utils/syscache.h"
  #include "pgstat.h"
  
*************** InitPostgres(const char *dbname, const c
*** 380,389 ****
  	on_shmem_exit(ShutdownPostgres, 0);
  
  	/*
! 	 * Start a new transaction here before first access to db
  	 */
  	if (!bootstrap)
  		StartTransactionCommand();
  
  	/*
  	 * Now that we have a transaction, we can take locks.  Take a writer's
--- 381,395 ----
  	on_shmem_exit(ShutdownPostgres, 0);
  
  	/*
! 	 * Start a new transaction here before first access to db, and get a
! 	 * snapshot.  We don't have a use for the snapshot itself, but we're
! 	 * interested in the secondary effect that it sets RecentGlobalXmin.
  	 */
  	if (!bootstrap)
+ 	{
  		StartTransactionCommand();
+ 		(void) GetTransactionSnapshot();
+ 	}
  
  	/*
  	 * Now that we have a transaction, we can take locks.  Take a writer's
