Tom Lane wrote:
> Bruce Momjian <br...@momjian.us> writes:
> > I propose I just remove the 8.4
> > test and always allow toast table names not to match --- the oids are
> > still checked and are preserved.
> 
> +1.  You'll still make the check for non-toast tables, of course?

Yes, only toast tables will skip the check.  Proposed patch attached.

-- 
  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
new file mode 100644
index e41ab2b..7b1ab36
*** a/contrib/pg_upgrade/info.c
--- b/contrib/pg_upgrade/info.c
*************** gen_db_file_maps(DbInfo *old_db, DbInfo 
*** 57,69 ****
  				   old_db->db_name, old_rel->reloid, new_rel->reloid);
  
  		/*
! 		 * In pre-8.4, TOAST table names change during CLUSTER;  in >= 8.4
! 		 * TOAST relation names always use heap table oids, hence we cannot
! 		 * check relation names when upgrading from pre-8.4.
  		 */
  		if (strcmp(old_rel->nspname, new_rel->nspname) != 0 ||
! 			((GET_MAJOR_VERSION(old_cluster.major_version) >= 804 ||
! 			  strcmp(old_rel->nspname, "pg_toast") != 0) &&
  			 strcmp(old_rel->relname, new_rel->relname) != 0))
  			pg_log(PG_FATAL, "Mismatch of relation names in database \"%s\": "
  				   "old name \"%s.%s\", new name \"%s.%s\"\n",
--- 57,73 ----
  				   old_db->db_name, old_rel->reloid, new_rel->reloid);
  
  		/*
! 		 * TOAST table names initially match the heap pg_class oid.
! 		 * However, in pre-8.4, TOAST table names change during CLUSTER, and
! 		 * in pre-9.0, TOAST table names change during ALTER TABLE.  Because
! 		 * an 8.3 or 8.4 system might be upgraded to 9.0 and then 9.1 (and
! 		 * still have a mismatch between toast table name and heap oid),
! 		 * we can't use the old cluster version to know if all toast
! 		 * table names match.  Hence we don't check a match of toast table
! 		 * names.
  		 */
  		if (strcmp(old_rel->nspname, new_rel->nspname) != 0 ||
! 			(strcmp(old_rel->nspname, "pg_toast") != 0 &&
  			 strcmp(old_rel->relname, new_rel->relname) != 0))
  			pg_log(PG_FATAL, "Mismatch of relation names in database \"%s\": "
  				   "old name \"%s.%s\", new name \"%s.%s\"\n",
-- 
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