Robert Haas wrote: > On Fri, Oct 28, 2011 at 10:16 AM, Bruce Momjian <br...@momjian.us> wrote: > > Robert Haas wrote: > >> On Fri, Oct 28, 2011 at 10:07 AM, Bruce Momjian <br...@momjian.us> wrote: > >> > OK, then the simplest fix, once you modify pg_dumpall, would be to > >> > modify pg_upgrade to remove reference to the postgres database in the > >> > new cluster if it doesn't exist in the old one. ?That would allow > >> > pg_upgrade to maintain a 1-1 matching of databases in the old and new > >> > cluster --- it allows the change to be locallized without affecting much > >> > code. > >> > >> That sounds just fine. ?+1. > > > > FYI, I don't want to modify pg_dumpall myself because I didn't want to > > have pg_upgrade forcing a pg_dumpall change that applies to > > non-binary-upgrade dumps. ?pg_dumpall is too important. ?I am fine if > > someone else does it, though. ?:-) > > OK, done.
OK, the attached, applied patch removes the pg_upgrade dependency on the 'postgres' database existing in the new cluster. However, vacuumdb, used by pg_upgrade, still has this dependency: conn = connectDatabase("postgres", host, port, username, prompt_password, progname); In fact, all the /scripts binaries use the postgres database, except for createdb/dropdb, which has this heuristic: /* * Connect to the 'postgres' database by default, except have the * 'postgres' user use 'template1' so he can create the 'postgres' * database. */ conn = connectDatabase(strcmp(dbname, "postgres") == 0 ? "template1" : "postgres", host, port, username, prompt_password, progname); This makes sense because you might be creating or dropping the postgres database. Do we want these to have smarter database selection code? I will now work on code to allow the old cluster to optionally not have a postgres database. -- Bruce Momjian <br...@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +
diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c new file mode 100644 index 273561e..12df463 *** a/contrib/pg_upgrade/pg_upgrade.c --- b/contrib/pg_upgrade/pg_upgrade.c *************** static void set_frozenxids(void); *** 52,60 **** static void setup(char *argv0, bool live_check); static void cleanup(void); - /* This is the database used by pg_dumpall to restore global tables */ - #define GLOBAL_DUMP_DB "postgres" - ClusterInfo old_cluster, new_cluster; OSInfo os_info; --- 52,57 ---- *************** prepare_new_databases(void) *** 233,242 **** prep_status("Creating databases in the new cluster"); /* ! * Install support functions in the global-restore database to preserve ! * pg_authid.oid. */ ! install_support_functions_in_new_db(GLOBAL_DUMP_DB); /* * We have to create the databases first so we can install support --- 230,241 ---- prep_status("Creating databases in the new cluster"); /* ! * Install support functions in the global-object restore database to ! * preserve pg_authid.oid. pg_dumpall uses 'template0' as its template ! * database so objects we add into 'template1' are not propogated. They ! * are removed on pg_upgrade exit. */ ! install_support_functions_in_new_db("template1"); /* * We have to create the databases first so we can install support *************** create_new_objects(void) *** 270,276 **** DbInfo *new_db = &new_cluster.dbarr.dbs[dbnum]; /* skip db we already installed */ ! if (strcmp(new_db->db_name, GLOBAL_DUMP_DB) != 0) install_support_functions_in_new_db(new_db->db_name); } check_ok(); --- 269,275 ---- DbInfo *new_db = &new_cluster.dbarr.dbs[dbnum]; /* skip db we already installed */ ! if (strcmp(new_db->db_name, "template1") != 0) install_support_functions_in_new_db(new_db->db_name); } check_ok();
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers