1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Allow pg_upgrade to upgrade an old cluster that doesn't have a

'postgres' database.
This commit is contained in:
Bruce Momjian
2011-11-01 13:49:03 -04:00
parent 806a2aee37
commit a50d860ae1
3 changed files with 17 additions and 45 deletions

View File

@ -34,22 +34,30 @@ const char *
transfer_all_new_dbs(DbInfoArr *old_db_arr,
DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata)
{
int dbnum;
int old_dbnum, new_dbnum;
const char *msg = NULL;
prep_status("Restoring user relation files\n");
if (old_db_arr->ndbs != new_db_arr->ndbs)
pg_log(PG_FATAL, "old and new clusters have a different number of databases\n");
for (dbnum = 0; dbnum < old_db_arr->ndbs; dbnum++)
/* Scan the old cluster databases and transfer their files */
for (old_dbnum = new_dbnum = 0;
old_dbnum < old_db_arr->ndbs && new_dbnum < new_db_arr->ndbs;
old_dbnum++, new_dbnum++)
{
DbInfo *old_db = &old_db_arr->dbs[dbnum];
DbInfo *new_db = &new_db_arr->dbs[dbnum];
DbInfo *old_db = &old_db_arr->dbs[old_dbnum];
DbInfo *new_db = &new_db_arr->dbs[new_dbnum];
FileNameMap *mappings;
int n_maps;
pageCnvCtx *pageConverter = NULL;
/*
* Advance past any databases that exist in the new cluster
* but not in the old, e.g. "postgres".
*/
while (strcmp(old_db->db_name, new_db->db_name) != 0 &&
new_dbnum < new_db_arr->ndbs)
new_db = &new_db_arr->dbs[++new_dbnum];
if (strcmp(old_db->db_name, new_db->db_name) != 0)
pg_log(PG_FATAL, "old and new databases have different names: old \"%s\", new \"%s\"\n",
old_db->db_name, new_db->db_name);