I got a report from someone using pg_upgrade coming from PG 8.3 ---
turns out we didn't rename toast tables to match the new relfilenode in
pre-8.4, so the attached applied patch avoids the check for these cases.
This check is new in pg_upgrade for 9.1.

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

  + It's impossible for everything to be true. +
commit 9e5bed2df1693a46dfaed862d7462ba2379f8f79
Author: Bruce Momjian <br...@momjian.us>
Date:   Sat Mar 5 21:12:21 2011 -0500

    Restructure pg_upgrade checks because pre-8.4 Postgres did not rename
    toast file names to match the new relfilenode.

diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c
index a502507..ad7edc4 100644
*** a/contrib/pg_upgrade/info.c
--- b/contrib/pg_upgrade/info.c
*************** gen_db_file_maps(DbInfo *old_db, DbInfo 
*** 51,59 ****
  		RelInfo    *new_rel = &new_db->rel_arr.rels[relnum];
  
  		if (old_rel->reloid != new_rel->reloid)
! 			pg_log(PG_FATAL, "mismatch of relation id: database \"%s\", old relid %d, new relid %d\n",
  			old_db->db_name, old_rel->reloid, new_rel->reloid);
! 	
  		create_rel_filename_map(old_pgdata, new_pgdata, old_db, new_db,
  				old_rel, new_rel, maps + num_maps);
  		num_maps++;
--- 51,68 ----
  		RelInfo    *new_rel = &new_db->rel_arr.rels[relnum];
  
  		if (old_rel->reloid != new_rel->reloid)
! 			pg_log(PG_FATAL, "Mismatch of relation id: database \"%s\", old relid %d, new relid %d\n",
  			old_db->db_name, old_rel->reloid, new_rel->reloid);
! 
! 		/* toast names were not renamed to match their relfilenodes in pre-8.4 */
! 		if (GET_MAJOR_VERSION(old_cluster.major_version) >= 804 &&
! 			(strcmp(old_rel->nspname, new_rel->nspname) != 0 ||
! 		     strcmp(old_rel->relname, new_rel->relname) != 0))
! 			pg_log(PG_FATAL, "Mismatch of relation names: database \"%s\", "
! 				"old rel %s.%s, new rel %s.%s\n",
! 				old_db->db_name, old_rel->nspname, old_rel->relname,
! 				new_rel->nspname, new_rel->relname);
! 
  		create_rel_filename_map(old_pgdata, new_pgdata, old_db, new_db,
  				old_rel, new_rel, maps + num_maps);
  		num_maps++;
*************** create_rel_filename_map(const char *old_
*** 104,115 ****
  	/* new_relfilenode will match old and new pg_class.oid */
  	map->new_relfilenode = new_rel->relfilenode;
  
- 	if (strcmp(old_rel->nspname, new_rel->nspname) != 0 ||
- 	    strcmp(old_rel->relname, new_rel->relname) != 0)
- 		pg_log(PG_FATAL, "mismatch of relation id: database \"%s\", old rel %s.%s, new rel %s.%s\n",
- 			old_db->db_name, old_rel->nspname, old_rel->relname,
- 			new_rel->nspname, new_rel->relname);
- 
  	/* 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);
--- 113,118 ----
-- 
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