diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c
index 294f58b..d3e1fef 100644
*** a/contrib/pg_upgrade/pg_upgrade.c
--- b/contrib/pg_upgrade/pg_upgrade.c
*************** static void set_frozenxids(void);
*** 50,55 ****
--- 50,58 ----
  static void setup(char *argv0, bool live_check);
  static void cleanup(void);
  
+ /* This is the database used by pg_dumpall to restore global tables */
+ #define GLOBAL_DUMP_DB	"postgres"
+ 
  ClusterInfo old_cluster, new_cluster;
  OSInfo		os_info;
  
*************** prepare_new_databases(void)
*** 226,235 ****
  	prep_status("Creating databases in the new cluster");
  
  	/*
! 	 *	Install support functions in the database accessed by
! 	 *	GLOBALS_DUMP_FILE because it can preserve pg_authid.oid.
  	 */
! 	install_support_functions_in_new_db(os_info.user);
  
  	/*
  	 * We have to create the databases first so we can install support
--- 229,238 ----
  	prep_status("Creating databases in the new cluster");
  
  	/*
! 	 *	Install support functions in the global-restore database
! 	 *	to preserve pg_authid.oid.
  	 */
! 	install_support_functions_in_new_db(GLOBAL_DUMP_DB);
  
  	/*
  	 * We have to create the databases first so we can install support
*************** create_new_objects(void)
*** 266,272 ****
  		DbInfo	   *new_db = &new_cluster.dbarr.dbs[dbnum];
  
  		/* skip db we already installed */
! 		if (strcmp(new_db->db_name, os_info.user) != 0)
  			install_support_functions_in_new_db(new_db->db_name);
  	}
  	check_ok();
--- 269,275 ----
  		DbInfo	   *new_db = &new_cluster.dbarr.dbs[dbnum];
  
  		/* skip db we already installed */
! 		if (strcmp(new_db->db_name, GLOBAL_DUMP_DB) != 0)
  			install_support_functions_in_new_db(new_db->db_name);
  	}
  	check_ok();
