The attached, applied patch for pg_upgrade tracks only one copy of
namespace/relname in FileNameMap because the old and new values are
identical.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c
index fb6ba75..301f6bb 100644
*** /tmp/pgdiff.28692/OjPD3a_info.c	Fri Jan  7 22:36:02 2011
--- contrib/pg_upgrade/info.c	Fri Jan  7 22:31:16 2011
*************** gen_db_file_maps(DbInfo *old_db, DbInfo 
*** 54,60 ****
  		if (strcmp(old_rel->nspname, "pg_toast") == 0)
  			continue;
  
! 		/* old/new non-toast relation names match */
  		new_rel = relarr_lookup_rel_name(&new_cluster, &new_db->rel_arr,
  								   old_rel->nspname, old_rel->relname);
  
--- 54,60 ----
  		if (strcmp(old_rel->nspname, "pg_toast") == 0)
  			continue;
  
! 		/* old/new relation names always match */
  		new_rel = relarr_lookup_rel_name(&new_cluster, &new_db->rel_arr,
  								   old_rel->nspname, old_rel->relname);
  
*************** create_rel_filename_map(const char *old_
*** 135,145 ****
  	map->old_relfilenode = old_rel->relfilenode;
  	map->new_relfilenode = new_rel->relfilenode;
  
! 	/* used only for logging and error reporing */
! 	snprintf(map->old_nspname, sizeof(map->old_nspname), "%s", old_rel->nspname);
! 	snprintf(map->new_nspname, sizeof(map->new_nspname), "%s", new_rel->nspname);
! 	snprintf(map->old_relname, sizeof(map->old_relname), "%s", old_rel->relname);
! 	snprintf(map->new_relname, sizeof(map->new_relname), "%s", new_rel->relname);
  }
  
  
--- 135,143 ----
  	map->old_relfilenode = old_rel->relfilenode;
  	map->new_relfilenode = new_rel->relfilenode;
  
! 	/* used only for logging and error reporing, old/new are identical */
! 	snprintf(map->nspname, sizeof(map->nspname), "%s", old_rel->nspname);
! 	snprintf(map->relname, sizeof(map->relname), "%s", old_rel->relname);
  }
  
  
*************** print_maps(FileNameMap *maps, int n, con
*** 153,162 ****
  		pg_log(PG_DEBUG, "mappings for db %s:\n", dbName);
  
  		for (mapnum = 0; mapnum < n; mapnum++)
! 			pg_log(PG_DEBUG, "%s.%s:%u ==> %s.%s:%u\n",
! 				   maps[mapnum].old_nspname, maps[mapnum].old_relname,
  				   maps[mapnum].old_relfilenode,
- 				   maps[mapnum].new_nspname, maps[mapnum].new_relname,
  				   maps[mapnum].new_relfilenode);
  
  		pg_log(PG_DEBUG, "\n\n");
--- 151,159 ----
  		pg_log(PG_DEBUG, "mappings for db %s:\n", dbName);
  
  		for (mapnum = 0; mapnum < n; mapnum++)
! 			pg_log(PG_DEBUG, "%s.%s: %u to %u\n",
! 				   maps[mapnum].nspname, maps[mapnum].relname,
  				   maps[mapnum].old_relfilenode,
  				   maps[mapnum].new_relfilenode);
  
  		pg_log(PG_DEBUG, "\n\n");
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 265,271 ****
  	char		query[QUERY_ALLOC];
  
  	/*
! 	 * pg_largeobject contains user data that does not appear the pg_dumpall
  	 * --schema-only output, so we have to copy that system table heap and
  	 * index.  Ideally we could just get the relfilenode from template1 but
  	 * pg_largeobject_loid_pn_index's relfilenode can change if the table was
--- 262,268 ----
  	char		query[QUERY_ALLOC];
  
  	/*
! 	 * pg_largeobject contains user data that does not appear in pg_dumpall
  	 * --schema-only output, so we have to copy that system table heap and
  	 * index.  Ideally we could just get the relfilenode from template1 but
  	 * pg_largeobject_loid_pn_index's relfilenode can change if the table was
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
index 01eddfb..95db4dd 100644
*** /tmp/pgdiff.28692/cozDUc_pg_upgrade.h	Fri Jan  7 22:36:02 2011
--- contrib/pg_upgrade/pg_upgrade.h	Fri Jan  7 22:27:21 2011
*************** typedef struct
*** 94,104 ****
  	Oid			old_relfilenode;
  	Oid			new_relfilenode;
  	/* the rest are used only for logging and error reporting */
! 	char		old_nspname[NAMEDATALEN];		/* namespaces */
! 	char		new_nspname[NAMEDATALEN];
! 	/* old/new relnames differ for toast tables and toast indexes */
! 	char		old_relname[NAMEDATALEN];
! 	char		new_relname[NAMEDATALEN];
  } FileNameMap;
  
  /*
--- 94,101 ----
  	Oid			old_relfilenode;
  	Oid			new_relfilenode;
  	/* the rest are used only for logging and error reporting */
! 	char		nspname[NAMEDATALEN];		/* namespaces */
! 	char		relname[NAMEDATALEN];
  } FileNameMap;
  
  /*
diff --git a/contrib/pg_upgrade/relfilenode.c b/contrib/pg_upgrade/relfilenode.c
index 33c2c3e..b30f5e0 100644
*** /tmp/pgdiff.28692/yrt6Fb_relfilenode.c	Fri Jan  7 22:36:02 2011
--- contrib/pg_upgrade/relfilenode.c	Fri Jan  7 22:30:53 2011
*************** static void transfer_single_new_db(pageC
*** 17,24 ****
  					   FileNameMap *maps, int size);
  static void transfer_relfile(pageCnvCtx *pageConverter,
  				 const char *fromfile, const char *tofile,
! 				 const char *old_nspname, const char *new_nspname,
! 				 const char *old_relname, const char *new_relname);
  
  /* used by scandir(), must be global */
  char		scandir_file_pattern[MAXPGPATH];
--- 17,23 ----
  					   FileNameMap *maps, int size);
  static void transfer_relfile(pageCnvCtx *pageConverter,
  				 const char *fromfile, const char *tofile,
! 				 const char *nspname, const char *relname);
  
  /* used by scandir(), must be global */
  char		scandir_file_pattern[MAXPGPATH];
*************** transfer_single_new_db(pageCnvCtx *pageC
*** 149,156 ****
  		 */
  		unlink(new_file);
  		transfer_relfile(pageConverter, old_file, new_file,
! 						 maps[mapnum].old_nspname, maps[mapnum].new_nspname,
! 						 maps[mapnum].old_relname, maps[mapnum].new_relname);
  
  		/* fsm/vm files added in PG 8.4 */
  		if (GET_MAJOR_VERSION(old_cluster.major_version) >= 804)
--- 148,154 ----
  		 */
  		unlink(new_file);
  		transfer_relfile(pageConverter, old_file, new_file,
! 						 maps[mapnum].nspname, maps[mapnum].relname);
  
  		/* fsm/vm files added in PG 8.4 */
  		if (GET_MAJOR_VERSION(old_cluster.major_version) >= 804)
*************** transfer_single_new_db(pageCnvCtx *pageC
*** 173,180 ****
  
  					unlink(new_file);
  					transfer_relfile(pageConverter, old_file, new_file,
! 							  maps[mapnum].old_nspname, maps[mapnum].new_nspname,
! 							  maps[mapnum].old_relname, maps[mapnum].new_relname);
  				}
  			}
  		}
--- 171,177 ----
  
  					unlink(new_file);
  					transfer_relfile(pageConverter, old_file, new_file,
! 							  maps[mapnum].nspname, maps[mapnum].relname);
  				}
  			}
  		}
*************** transfer_single_new_db(pageCnvCtx *pageC
*** 201,208 ****
  
  				unlink(new_file);
  				transfer_relfile(pageConverter, old_file, new_file,
! 							  maps[mapnum].old_nspname, maps[mapnum].new_nspname,
! 							  maps[mapnum].old_relname, maps[mapnum].new_relname);
  			}
  		}
  	}
--- 198,204 ----
  
  				unlink(new_file);
  				transfer_relfile(pageConverter, old_file, new_file,
! 							  maps[mapnum].nspname, maps[mapnum].relname);
  			}
  		}
  	}
*************** transfer_single_new_db(pageCnvCtx *pageC
*** 224,231 ****
   */
  static void
  transfer_relfile(pageCnvCtx *pageConverter, const char *old_file,
! 		 const char *new_file, const char *old_nspname, const char *new_nspname,
! 		 const char *old_relname, const char *new_relname)
  {
  	const char *msg;
  
--- 220,226 ----
   */
  static void
  transfer_relfile(pageCnvCtx *pageConverter, const char *old_file,
! 		 const char *new_file, const char *nspname, const char *relname)
  {
  	const char *msg;
  
*************** transfer_relfile(pageCnvCtx *pageConvert
*** 238,245 ****
  		pg_log(PG_INFO, "copying %s to %s\n", old_file, new_file);
  
  		if ((msg = copyAndUpdateFile(pageConverter, old_file, new_file, true)) != NULL)
! 			pg_log(PG_FATAL, "error while copying %s.%s(%s) to %s.%s(%s): %s\n",
! 				   old_nspname, old_relname, old_file, new_nspname, new_relname, new_file, msg);
  	}
  	else
  	{
--- 233,240 ----
  		pg_log(PG_INFO, "copying %s to %s\n", old_file, new_file);
  
  		if ((msg = copyAndUpdateFile(pageConverter, old_file, new_file, true)) != NULL)
! 			pg_log(PG_FATAL, "error while copying %s.%s (%s to %s): %s\n",
! 				   nspname, relname, old_file, new_file, msg);
  	}
  	else
  	{
*************** transfer_relfile(pageCnvCtx *pageConvert
*** 247,255 ****
  
  		if ((msg = linkAndUpdateFile(pageConverter, old_file, new_file)) != NULL)
  			pg_log(PG_FATAL,
! 			   "error while creating link from %s.%s(%s) to %s.%s(%s): %s\n",
! 				   old_nspname, old_relname, old_file, new_nspname, new_relname,
! 				   new_file, msg);
  	}
  	return;
  }
--- 242,249 ----
  
  		if ((msg = linkAndUpdateFile(pageConverter, old_file, new_file)) != NULL)
  			pg_log(PG_FATAL,
! 			   "error while creating link from %s.%s (%s to %s): %s\n",
! 				   nspname, relname, old_file, new_file, msg);
  	}
  	return;
  }
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to