In pg_upgrade, track only one copy of namespace/relname in FileNameMap

because the old and new values are identical.
This commit is contained in:
Bruce Momjian 2011-01-07 22:36:51 -05:00
parent 519c008a96
commit f75383e6e8
3 changed files with 18 additions and 30 deletions

View File

@ -54,7 +54,7 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
if (strcmp(old_rel->nspname, "pg_toast") == 0)
continue;
/* old/new non-toast relation names match */
/* old/new relation names always match */
new_rel = relarr_lookup_rel_name(&new_cluster, &new_db->rel_arr,
old_rel->nspname, old_rel->relname);
@ -135,11 +135,9 @@ create_rel_filename_map(const char *old_data, const char *new_data,
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);
/* 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);
}
@ -153,10 +151,9 @@ print_maps(FileNameMap *maps, int n, const char *dbName)
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,
pg_log(PG_DEBUG, "%s.%s: %u to %u\n",
maps[mapnum].nspname, maps[mapnum].relname,
maps[mapnum].old_relfilenode,
maps[mapnum].new_nspname, maps[mapnum].new_relname,
maps[mapnum].new_relfilenode);
pg_log(PG_DEBUG, "\n\n");
@ -265,7 +262,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
char query[QUERY_ALLOC];
/*
* pg_largeobject contains user data that does not appear the pg_dumpall
* 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

View File

@ -94,11 +94,8 @@ typedef struct
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];
char nspname[NAMEDATALEN]; /* namespaces */
char relname[NAMEDATALEN];
} FileNameMap;
/*

View File

@ -17,8 +17,7 @@ static void transfer_single_new_db(pageCnvCtx *pageConverter,
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);
const char *nspname, const char *relname);
/* used by scandir(), must be global */
char scandir_file_pattern[MAXPGPATH];
@ -149,8 +148,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
*/
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);
maps[mapnum].nspname, maps[mapnum].relname);
/* fsm/vm files added in PG 8.4 */
if (GET_MAJOR_VERSION(old_cluster.major_version) >= 804)
@ -173,8 +171,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
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);
maps[mapnum].nspname, maps[mapnum].relname);
}
}
}
@ -201,8 +198,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
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);
maps[mapnum].nspname, maps[mapnum].relname);
}
}
}
@ -224,8 +220,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
*/
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 *new_file, const char *nspname, const char *relname)
{
const char *msg;
@ -238,8 +233,8 @@ transfer_relfile(pageCnvCtx *pageConverter, const char *old_file,
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);
pg_log(PG_FATAL, "error while copying %s.%s (%s to %s): %s\n",
nspname, relname, old_file, new_file, msg);
}
else
{
@ -247,9 +242,8 @@ transfer_relfile(pageCnvCtx *pageConverter, const char *old_file,
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);
"error while creating link from %s.%s (%s to %s): %s\n",
nspname, relname, old_file, new_file, msg);
}
return;
}