diff -c -r pgsql.orig/doc/src/sgml/ref/pg_dumpall.sgml pgsql/doc/src/sgml/ref/pg_dumpall.sgml
*** pgsql.orig/doc/src/sgml/ref/pg_dumpall.sgml Mon Jan 15 13:26:07 2007
--- pgsql/doc/src/sgml/ref/pg_dumpall.sgml Mon Jan 15 13:34:31 2007
***************
*** 23,28 ****
--- 23,29 ----
pg_dumpall
option
+ dbname
***************
*** 354,359 ****
--- 355,372 ----
+
+
+ dbname
+
+
+ Specifies the name of the database to connect to to dump global
+ objects and discover what other databases should be dumped. If
+ not specified, the postgres
database will be used,
+ and if that does not exist, template1
will be used.
+
+
+
diff -c -r pgsql.orig/src/bin/pg_dump/pg_dumpall.c pgsql/src/bin/pg_dump/pg_dumpall.c
*** pgsql.orig/src/bin/pg_dump/pg_dumpall.c Mon Jan 15 13:26:07 2007
--- pgsql/src/bin/pg_dump/pg_dumpall.c Mon Jan 15 12:52:34 2007
***************
*** 75,80 ****
--- 75,81 ----
char *pghost = NULL;
char *pgport = NULL;
char *pguser = NULL;
+ char *pgdb = NULL;
bool force_password = false;
bool data_only = false;
bool globals_only = false;
***************
*** 299,304 ****
--- 300,312 ----
if (use_setsessauth)
appendPQExpBuffer(pgdumpopts, " --use-set-session-authorization");
+ /* If there is an argument left, assume it's a database name */
+ if (optind < argc)
+ {
+ pgdb = argv[optind];
+ optind++;
+ }
+
if (optind < argc)
{
fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
***************
*** 337,351 ****
}
/*
! * First try to connect to database "postgres", and failing that
* "template1". "postgres" is the preferred choice for 8.1 and later
* servers, but it usually will not exist on older ones.
*/
! conn = connectDatabase("postgres", pghost, pgport, pguser,
force_password, false);
! if (!conn)
! conn = connectDatabase("template1", pghost, pgport, pguser,
! force_password, true);
/*
* Get the active encoding and the standard_conforming_strings setting, so
--- 345,384 ----
}
/*
! * If there was a database specified on the command line, use that,
! * otherwise try to connect to database "postgres", and failing that
* "template1". "postgres" is the preferred choice for 8.1 and later
* servers, but it usually will not exist on older ones.
*/
! if (pgdb)
! {
! conn = connectDatabase(pgdb, pghost, pgport, pguser,
! force_password, false);
!
! if (!conn)
! {
! fprintf(stderr, _("%s: could not connect to database \"%s\"\n"),
! progname, pgdb);
! exit(1);
! }
! }
! else
! {
! conn = connectDatabase("postgres", pghost, pgport, pguser,
force_password, false);
! if (!conn)
! conn = connectDatabase("template1", pghost, pgport, pguser,
! force_password, true);
!
! if (!conn)
! {
! fprintf(stderr, _("%s: could not connect to databases \"postgres\" or \"template1\". Please specify an alternative database\n"),
! progname);
! fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
! progname);
! exit(1);
! }
! }
/*
* Get the active encoding and the standard_conforming_strings setting, so