Index: src/backend/postmaster/autovacuum.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/postmaster/autovacuum.c,v
retrieving revision 1.71.2.3
diff -c -p -r1.71.2.3 autovacuum.c
*** src/backend/postmaster/autovacuum.c	14 Mar 2008 23:49:33 -0000	1.71.2.3
--- src/backend/postmaster/autovacuum.c	17 Jul 2008 17:14:58 -0000
*************** do_autovacuum(void)
*** 2098,2110 ****
  
  		/*
  		 * Save the relation name for a possible error message, to avoid a
! 		 * catalog lookup in case of an error.	Note: they must live in a
! 		 * long-lived memory context because we call vacuum and analyze in
! 		 * different transactions.
  		 */
  		datname = get_database_name(MyDatabaseId);
  		nspname = get_namespace_name(get_rel_namespace(tab->at_relid));
  		relname = get_rel_name(tab->at_relid);
  
  		/*
  		 * We will abort vacuuming the current table if something errors out,
--- 2098,2113 ----
  
  		/*
  		 * Save the relation name for a possible error message, to avoid a
! 		 * catalog lookup in case of an error.  If any of these return NULL,
! 		 * then the relation has been dropped since last we checked; skip it.
! 		 * Note: they must live in a long-lived memory context because we call
! 		 * vacuum and analyze in different transactions.
  		 */
  		datname = get_database_name(MyDatabaseId);
  		nspname = get_namespace_name(get_rel_namespace(tab->at_relid));
  		relname = get_rel_name(tab->at_relid);
+ 		if (!datname || !nspname || !relname)
+ 			goto deleted;
  
  		/*
  		 * We will abort vacuuming the current table if something errors out,
*************** do_autovacuum(void)
*** 2158,2168 ****
  
  		/* the PGPROC flags are reset at the next end of transaction */
  
  		/* be tidy */
  		pfree(tab);
! 		pfree(datname);
! 		pfree(nspname);
! 		pfree(relname);
  
  		/* remove my info from shared memory */
  		LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE);
--- 2161,2175 ----
  
  		/* the PGPROC flags are reset at the next end of transaction */
  
+ deleted:
  		/* be tidy */
  		pfree(tab);
! 		if (datname)
! 			pfree(datname);
! 		if (nspname)
! 			pfree(nspname);
! 		if (relname)
! 			pfree(relname);
  
  		/* remove my info from shared memory */
  		LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE);
