mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Adjust pg_upgrade "new database skip" code, e.g. 'postgres', to more
cleanly handle old/new database mismatches.
This commit is contained in:
parent
7ed3605675
commit
84b8fcaa92
@ -41,11 +41,10 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
|
|||||||
|
|
||||||
/* Scan the old cluster databases and transfer their files */
|
/* Scan the old cluster databases and transfer their files */
|
||||||
for (old_dbnum = new_dbnum = 0;
|
for (old_dbnum = new_dbnum = 0;
|
||||||
old_dbnum < old_db_arr->ndbs && new_dbnum < new_db_arr->ndbs;
|
old_dbnum < old_db_arr->ndbs;
|
||||||
old_dbnum++, new_dbnum++)
|
old_dbnum++, new_dbnum++)
|
||||||
{
|
{
|
||||||
DbInfo *old_db = &old_db_arr->dbs[old_dbnum];
|
DbInfo *old_db = &old_db_arr->dbs[old_dbnum], *new_db;
|
||||||
DbInfo *new_db = &new_db_arr->dbs[new_dbnum];
|
|
||||||
FileNameMap *mappings;
|
FileNameMap *mappings;
|
||||||
int n_maps;
|
int n_maps;
|
||||||
pageCnvCtx *pageConverter = NULL;
|
pageCnvCtx *pageConverter = NULL;
|
||||||
@ -55,13 +54,16 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
|
|||||||
* but not in the old, e.g. "postgres". (The user might
|
* but not in the old, e.g. "postgres". (The user might
|
||||||
* have removed the 'postgres' database from the old cluster.)
|
* have removed the 'postgres' database from the old cluster.)
|
||||||
*/
|
*/
|
||||||
while (strcmp(old_db->db_name, new_db->db_name) != 0 &&
|
for (; new_dbnum < new_db_arr->ndbs; new_dbnum++)
|
||||||
new_dbnum < new_db_arr->ndbs)
|
{
|
||||||
new_db = &new_db_arr->dbs[++new_dbnum];
|
new_db = &new_db_arr->dbs[new_dbnum];
|
||||||
|
if (strcmp(old_db->db_name, new_db->db_name) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(old_db->db_name, new_db->db_name) != 0)
|
if (new_dbnum >= new_db_arr->ndbs)
|
||||||
pg_log(PG_FATAL, "old and new databases have different names: old \"%s\", new \"%s\"\n",
|
pg_log(PG_FATAL, "old database \"%s\" not found in the new cluster\n",
|
||||||
old_db->db_name, new_db->db_name);
|
old_db->db_name);
|
||||||
|
|
||||||
n_maps = 0;
|
n_maps = 0;
|
||||||
mappings = gen_db_file_maps(old_db, new_db, &n_maps, old_pgdata,
|
mappings = gen_db_file_maps(old_db, new_db, &n_maps, old_pgdata,
|
||||||
|
Loading…
Reference in New Issue
Block a user