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

Commit84b8fca

Browse files
committed
Adjust pg_upgrade "new database skip" code, e.g. 'postgres', to more
cleanly handle old/new database mismatches.
1 parent7ed3605 commit84b8fca

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

‎contrib/pg_upgrade/relfilenode.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
4141

4242
/* Scan the old cluster databases and transfer their files */
4343
for (old_dbnum=new_dbnum=0;
44-
old_dbnum<old_db_arr->ndbs&&new_dbnum<new_db_arr->ndbs;
44+
old_dbnum<old_db_arr->ndbs;
4545
old_dbnum++,new_dbnum++)
4646
{
47-
DbInfo*old_db=&old_db_arr->dbs[old_dbnum];
48-
DbInfo*new_db=&new_db_arr->dbs[new_dbnum];
47+
DbInfo*old_db=&old_db_arr->dbs[old_dbnum],*new_db;
4948
FileNameMap*mappings;
5049
intn_maps;
5150
pageCnvCtx*pageConverter=NULL;
@@ -55,13 +54,16 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
5554
*but not in the old, e.g. "postgres". (The user might
5655
*have removed the 'postgres' database from the old cluster.)
5756
*/
58-
while (strcmp(old_db->db_name,new_db->db_name)!=0&&
59-
new_dbnum<new_db_arr->ndbs)
60-
new_db=&new_db_arr->dbs[++new_dbnum];
57+
for (;new_dbnum<new_db_arr->ndbs;new_dbnum++)
58+
{
59+
new_db=&new_db_arr->dbs[new_dbnum];
60+
if (strcmp(old_db->db_name,new_db->db_name)==0)
61+
break;
62+
}
6163

62-
if (strcmp(old_db->db_name,new_db->db_name)!=0)
63-
pg_log(PG_FATAL,"oldand new databases have different names: old\"%s\",new\"%s\"\n",
64-
old_db->db_name,new_db->db_name);
64+
if (new_dbnum >=new_db_arr->ndbs)
65+
pg_log(PG_FATAL,"olddatabase\"%s\" not found in thenewcluster\n",
66+
old_db->db_name);
6567

6668
n_maps=0;
6769
mappings=gen_db_file_maps(old_db,new_db,&n_maps,old_pgdata,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp