OSDN Git Service

Adjust pg_upgrade error message, array freeing, and add error check.
authorBruce Momjian <bruce@momjian.us>
Tue, 15 Feb 2011 20:00:07 +0000 (15:00 -0500)
committerBruce Momjian <bruce@momjian.us>
Tue, 15 Feb 2011 20:00:47 +0000 (15:00 -0500)
contrib/pg_upgrade/check.c
contrib/pg_upgrade/info.c
contrib/pg_upgrade/pg_upgrade.c
contrib/pg_upgrade/relfilenode.c

index 1103e36..2e6400e 100644 (file)
@@ -362,8 +362,6 @@ check_new_db_is_empty(void)
                }
        }
 
-       free_db_and_rel_infos(&new_cluster.dbarr);
-
        if (found)
                pg_log(PG_FATAL, "New cluster is not empty; exiting\n");
 }
index c041231..dbbc143 100644 (file)
@@ -104,6 +104,12 @@ 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, 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);
@@ -141,6 +147,9 @@ get_db_and_rel_infos(ClusterInfo *cluster)
 {
        int                     dbnum;
 
+       if (cluster->dbarr)
+               free_db_and_rel_infos(cluster->dbarr);
+
        get_db_infos(cluster);
 
        for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
index 368c0e7..e93ac3b 100644 (file)
@@ -286,7 +286,6 @@ create_new_objects(void)
        check_ok();
 
        /* regenerate now that we have objects in the databases */
-       free_db_and_rel_infos(&new_cluster.dbarr);
        get_db_and_rel_infos(&new_cluster);
 
        uninstall_support_functions_from_new_cluster();
index ca96407..d111b13 100644 (file)
@@ -49,7 +49,7 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
                pageCnvCtx *pageConverter = NULL;
 
                if (strcmp(old_db->db_name, new_db->db_name) != 0)
-                       pg_log(PG_FATAL, "old and new databases have different names: old \"%s\", new \"%s\"\n",
+                       pg_log(PG_FATAL, "old and new databases have different names: old \"%s\", new \"%s\"\n",
                                old_db->db_name, new_db->db_name);
                
                n_maps = 0;