From 9e5bed2df1693a46dfaed862d7462ba2379f8f79 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 5 Mar 2011 21:12:21 -0500 Subject: [PATCH] Restructure pg_upgrade checks because pre-8.4 Postgres did not rename toast file names to match the new relfilenode. --- contrib/pg_upgrade/info.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c index a502507fb2..ad7edc4e79 100644 --- a/contrib/pg_upgrade/info.c +++ b/contrib/pg_upgrade/info.c @@ -51,9 +51,18 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db, 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", + 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++; @@ -104,12 +113,6 @@ create_rel_filename_map(const char *old_data, const char *new_data, /* 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);