Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf75383e

Browse files
committed
In pg_upgrade, track only one copy of namespace/relname in FileNameMap
because the old and new values are identical.
1 parent519c008 commitf75383e

File tree

3 files changed

+18
-30
lines changed

3 files changed

+18
-30
lines changed

‎contrib/pg_upgrade/info.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
5454
if (strcmp(old_rel->nspname,"pg_toast")==0)
5555
continue;
5656

57-
/* old/newnon-toastrelation names match */
57+
/* old/new relation names always match */
5858
new_rel=relarr_lookup_rel_name(&new_cluster,&new_db->rel_arr,
5959
old_rel->nspname,old_rel->relname);
6060

@@ -135,11 +135,9 @@ create_rel_filename_map(const char *old_data, const char *new_data,
135135
map->old_relfilenode=old_rel->relfilenode;
136136
map->new_relfilenode=new_rel->relfilenode;
137137

138-
/* used only for logging and error reporing */
139-
snprintf(map->old_nspname,sizeof(map->old_nspname),"%s",old_rel->nspname);
140-
snprintf(map->new_nspname,sizeof(map->new_nspname),"%s",new_rel->nspname);
141-
snprintf(map->old_relname,sizeof(map->old_relname),"%s",old_rel->relname);
142-
snprintf(map->new_relname,sizeof(map->new_relname),"%s",new_rel->relname);
138+
/* used only for logging and error reporing, old/new are identical */
139+
snprintf(map->nspname,sizeof(map->nspname),"%s",old_rel->nspname);
140+
snprintf(map->relname,sizeof(map->relname),"%s",old_rel->relname);
143141
}
144142

145143

@@ -153,10 +151,9 @@ print_maps(FileNameMap *maps, int n, const char *dbName)
153151
pg_log(PG_DEBUG,"mappings for db %s:\n",dbName);
154152

155153
for (mapnum=0;mapnum<n;mapnum++)
156-
pg_log(PG_DEBUG,"%s.%s:%u==> %s.%s:%u\n",
157-
maps[mapnum].old_nspname,maps[mapnum].old_relname,
154+
pg_log(PG_DEBUG,"%s.%s:%uto%u\n",
155+
maps[mapnum].nspname,maps[mapnum].relname,
158156
maps[mapnum].old_relfilenode,
159-
maps[mapnum].new_nspname,maps[mapnum].new_relname,
160157
maps[mapnum].new_relfilenode);
161158

162159
pg_log(PG_DEBUG,"\n\n");
@@ -265,7 +262,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
265262
charquery[QUERY_ALLOC];
266263

267264
/*
268-
* pg_largeobject contains user data that does not appearthe pg_dumpall
265+
* pg_largeobject contains user data that does not appearin pg_dumpall
269266
* --schema-only output, so we have to copy that system table heap and
270267
* index. Ideally we could just get the relfilenode from template1 but
271268
* pg_largeobject_loid_pn_index's relfilenode can change if the table was

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,8 @@ typedef struct
9494
Oidold_relfilenode;
9595
Oidnew_relfilenode;
9696
/* the rest are used only for logging and error reporting */
97-
charold_nspname[NAMEDATALEN];/* namespaces */
98-
charnew_nspname[NAMEDATALEN];
99-
/* old/new relnames differ for toast tables and toast indexes */
100-
charold_relname[NAMEDATALEN];
101-
charnew_relname[NAMEDATALEN];
97+
charnspname[NAMEDATALEN];/* namespaces */
98+
charrelname[NAMEDATALEN];
10299
}FileNameMap;
103100

104101
/*

‎contrib/pg_upgrade/relfilenode.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ static void transfer_single_new_db(pageCnvCtx *pageConverter,
1717
FileNameMap*maps,intsize);
1818
staticvoidtransfer_relfile(pageCnvCtx*pageConverter,
1919
constchar*fromfile,constchar*tofile,
20-
constchar*old_nspname,constchar*new_nspname,
21-
constchar*old_relname,constchar*new_relname);
20+
constchar*nspname,constchar*relname);
2221

2322
/* used by scandir(), must be global */
2423
charscandir_file_pattern[MAXPGPATH];
@@ -149,8 +148,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
149148
*/
150149
unlink(new_file);
151150
transfer_relfile(pageConverter,old_file,new_file,
152-
maps[mapnum].old_nspname,maps[mapnum].new_nspname,
153-
maps[mapnum].old_relname,maps[mapnum].new_relname);
151+
maps[mapnum].nspname,maps[mapnum].relname);
154152

155153
/* fsm/vm files added in PG 8.4 */
156154
if (GET_MAJOR_VERSION(old_cluster.major_version) >=804)
@@ -173,8 +171,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
173171

174172
unlink(new_file);
175173
transfer_relfile(pageConverter,old_file,new_file,
176-
maps[mapnum].old_nspname,maps[mapnum].new_nspname,
177-
maps[mapnum].old_relname,maps[mapnum].new_relname);
174+
maps[mapnum].nspname,maps[mapnum].relname);
178175
}
179176
}
180177
}
@@ -201,8 +198,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
201198

202199
unlink(new_file);
203200
transfer_relfile(pageConverter,old_file,new_file,
204-
maps[mapnum].old_nspname,maps[mapnum].new_nspname,
205-
maps[mapnum].old_relname,maps[mapnum].new_relname);
201+
maps[mapnum].nspname,maps[mapnum].relname);
206202
}
207203
}
208204
}
@@ -224,8 +220,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
224220
*/
225221
staticvoid
226222
transfer_relfile(pageCnvCtx*pageConverter,constchar*old_file,
227-
constchar*new_file,constchar*old_nspname,constchar*new_nspname,
228-
constchar*old_relname,constchar*new_relname)
223+
constchar*new_file,constchar*nspname,constchar*relname)
229224
{
230225
constchar*msg;
231226

@@ -238,18 +233,17 @@ transfer_relfile(pageCnvCtx *pageConverter, const char *old_file,
238233
pg_log(PG_INFO,"copying %s to %s\n",old_file,new_file);
239234

240235
if ((msg=copyAndUpdateFile(pageConverter,old_file,new_file, true))!=NULL)
241-
pg_log(PG_FATAL,"error while copying %s.%s(%s) to%s.%s(%s): %s\n",
242-
old_nspname,old_relname,old_file,new_nspname,new_relname,new_file,msg);
236+
pg_log(PG_FATAL,"error while copying %s.%s(%s to %s): %s\n",
237+
nspname,relname,old_file,new_file,msg);
243238
}
244239
else
245240
{
246241
pg_log(PG_INFO,"linking %s to %s\n",old_file,new_file);
247242

248243
if ((msg=linkAndUpdateFile(pageConverter,old_file,new_file))!=NULL)
249244
pg_log(PG_FATAL,
250-
"error while creating link from %s.%s(%s) to %s.%s(%s): %s\n",
251-
old_nspname,old_relname,old_file,new_nspname,new_relname,
252-
new_file,msg);
245+
"error while creating link from %s.%s (%s to %s): %s\n",
246+
nspname,relname,old_file,new_file,msg);
253247
}
254248
return;
255249
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp