Commit f75383e6 authored by Bruce Momjian's avatar Bruce Momjian

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

because the old and new values are identical.
parent 519c008a
...@@ -54,7 +54,7 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db, ...@@ -54,7 +54,7 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
if (strcmp(old_rel->nspname, "pg_toast") == 0) if (strcmp(old_rel->nspname, "pg_toast") == 0)
continue; 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, new_rel = relarr_lookup_rel_name(&new_cluster, &new_db->rel_arr,
old_rel->nspname, old_rel->relname); old_rel->nspname, old_rel->relname);
...@@ -135,11 +135,9 @@ create_rel_filename_map(const char *old_data, const char *new_data, ...@@ -135,11 +135,9 @@ create_rel_filename_map(const char *old_data, const char *new_data,
map->old_relfilenode = old_rel->relfilenode; map->old_relfilenode = old_rel->relfilenode;
map->new_relfilenode = new_rel->relfilenode; map->new_relfilenode = new_rel->relfilenode;
/* used only for logging and error reporing */ /* used only for logging and error reporing, old/new are identical */
snprintf(map->old_nspname, sizeof(map->old_nspname), "%s", old_rel->nspname); snprintf(map->nspname, sizeof(map->nspname), "%s", old_rel->nspname);
snprintf(map->new_nspname, sizeof(map->new_nspname), "%s", new_rel->nspname); snprintf(map->relname, sizeof(map->relname), "%s", old_rel->relname);
snprintf(map->old_relname, sizeof(map->old_relname), "%s", old_rel->relname);
snprintf(map->new_relname, sizeof(map->new_relname), "%s", new_rel->relname);
} }
...@@ -153,10 +151,9 @@ print_maps(FileNameMap *maps, int n, const char *dbName) ...@@ -153,10 +151,9 @@ print_maps(FileNameMap *maps, int n, const char *dbName)
pg_log(PG_DEBUG, "mappings for db %s:\n", dbName); pg_log(PG_DEBUG, "mappings for db %s:\n", dbName);
for (mapnum = 0; mapnum < n; mapnum++) for (mapnum = 0; mapnum < n; mapnum++)
pg_log(PG_DEBUG, "%s.%s:%u ==> %s.%s:%u\n", pg_log(PG_DEBUG, "%s.%s: %u to %u\n",
maps[mapnum].old_nspname, maps[mapnum].old_relname, maps[mapnum].nspname, maps[mapnum].relname,
maps[mapnum].old_relfilenode, maps[mapnum].old_relfilenode,
maps[mapnum].new_nspname, maps[mapnum].new_relname,
maps[mapnum].new_relfilenode); maps[mapnum].new_relfilenode);
pg_log(PG_DEBUG, "\n\n"); pg_log(PG_DEBUG, "\n\n");
...@@ -265,7 +262,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo) ...@@ -265,7 +262,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
char query[QUERY_ALLOC]; 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 * --schema-only output, so we have to copy that system table heap and
* index. Ideally we could just get the relfilenode from template1 but * index. Ideally we could just get the relfilenode from template1 but
* pg_largeobject_loid_pn_index's relfilenode can change if the table was * pg_largeobject_loid_pn_index's relfilenode can change if the table was
......
...@@ -94,11 +94,8 @@ typedef struct ...@@ -94,11 +94,8 @@ typedef struct
Oid old_relfilenode; Oid old_relfilenode;
Oid new_relfilenode; Oid new_relfilenode;
/* the rest are used only for logging and error reporting */ /* the rest are used only for logging and error reporting */
char old_nspname[NAMEDATALEN]; /* namespaces */ char nspname[NAMEDATALEN]; /* namespaces */
char new_nspname[NAMEDATALEN]; char relname[NAMEDATALEN];
/* old/new relnames differ for toast tables and toast indexes */
char old_relname[NAMEDATALEN];
char new_relname[NAMEDATALEN];
} FileNameMap; } FileNameMap;
/* /*
......
...@@ -17,8 +17,7 @@ static void transfer_single_new_db(pageCnvCtx *pageConverter, ...@@ -17,8 +17,7 @@ static void transfer_single_new_db(pageCnvCtx *pageConverter,
FileNameMap *maps, int size); FileNameMap *maps, int size);
static void transfer_relfile(pageCnvCtx *pageConverter, static void transfer_relfile(pageCnvCtx *pageConverter,
const char *fromfile, const char *tofile, const char *fromfile, const char *tofile,
const char *old_nspname, const char *new_nspname, const char *nspname, const char *relname);
const char *old_relname, const char *new_relname);
/* used by scandir(), must be global */ /* used by scandir(), must be global */
char scandir_file_pattern[MAXPGPATH]; char scandir_file_pattern[MAXPGPATH];
...@@ -149,8 +148,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter, ...@@ -149,8 +148,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
*/ */
unlink(new_file); unlink(new_file);
transfer_relfile(pageConverter, old_file, new_file, transfer_relfile(pageConverter, old_file, new_file,
maps[mapnum].old_nspname, maps[mapnum].new_nspname, maps[mapnum].nspname, maps[mapnum].relname);
maps[mapnum].old_relname, maps[mapnum].new_relname);
/* fsm/vm files added in PG 8.4 */ /* fsm/vm files added in PG 8.4 */
if (GET_MAJOR_VERSION(old_cluster.major_version) >= 804) if (GET_MAJOR_VERSION(old_cluster.major_version) >= 804)
...@@ -173,8 +171,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter, ...@@ -173,8 +171,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
unlink(new_file); unlink(new_file);
transfer_relfile(pageConverter, old_file, new_file, transfer_relfile(pageConverter, old_file, new_file,
maps[mapnum].old_nspname, maps[mapnum].new_nspname, maps[mapnum].nspname, maps[mapnum].relname);
maps[mapnum].old_relname, maps[mapnum].new_relname);
} }
} }
} }
...@@ -201,8 +198,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter, ...@@ -201,8 +198,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
unlink(new_file); unlink(new_file);
transfer_relfile(pageConverter, old_file, new_file, transfer_relfile(pageConverter, old_file, new_file,
maps[mapnum].old_nspname, maps[mapnum].new_nspname, maps[mapnum].nspname, maps[mapnum].relname);
maps[mapnum].old_relname, maps[mapnum].new_relname);
} }
} }
} }
...@@ -224,8 +220,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter, ...@@ -224,8 +220,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
*/ */
static void static void
transfer_relfile(pageCnvCtx *pageConverter, const char *old_file, transfer_relfile(pageCnvCtx *pageConverter, const char *old_file,
const char *new_file, const char *old_nspname, const char *new_nspname, const char *new_file, const char *nspname, const char *relname)
const char *old_relname, const char *new_relname)
{ {
const char *msg; const char *msg;
...@@ -238,8 +233,8 @@ transfer_relfile(pageCnvCtx *pageConverter, const char *old_file, ...@@ -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); pg_log(PG_INFO, "copying %s to %s\n", old_file, new_file);
if ((msg = copyAndUpdateFile(pageConverter, old_file, new_file, true)) != NULL) 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", pg_log(PG_FATAL, "error while copying %s.%s (%s to %s): %s\n",
old_nspname, old_relname, old_file, new_nspname, new_relname, new_file, msg); nspname, relname, old_file, new_file, msg);
} }
else else
{ {
...@@ -247,9 +242,8 @@ transfer_relfile(pageCnvCtx *pageConverter, const char *old_file, ...@@ -247,9 +242,8 @@ transfer_relfile(pageCnvCtx *pageConverter, const char *old_file,
if ((msg = linkAndUpdateFile(pageConverter, old_file, new_file)) != NULL) if ((msg = linkAndUpdateFile(pageConverter, old_file, new_file)) != NULL)
pg_log(PG_FATAL, pg_log(PG_FATAL,
"error while creating link from %s.%s(%s) to %s.%s(%s): %s\n", "error while creating link from %s.%s (%s to %s): %s\n",
old_nspname, old_relname, old_file, new_nspname, new_relname, nspname, relname, old_file, new_file, msg);
new_file, msg);
} }
return; return;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment