aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-04-23 23:36:33 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-04-23 23:36:33 +0000
commit5c48b253af966a91fb04cf0efe3b3d065bb005a6 (patch)
tree4507daa80e1e841015c4d23446c18d5fd6c8c84e
parentfae92fba43f789e0b260a10a947e0be2a30e8619 (diff)
downloadpostgresql-5c48b253af966a91fb04cf0efe3b3d065bb005a6.tar.gz
postgresql-5c48b253af966a91fb04cf0efe3b3d065bb005a6.zip
Behave sanely when database name is omitted from command line.
-rw-r--r--src/bin/pg_dump/pg_dump.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 1eb0ff95c29..3d8eb7b1ff0 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -22,7 +22,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.203 2001/04/22 21:34:13 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.204 2001/04/23 23:36:33 tgl Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
@@ -948,6 +948,19 @@ main(int argc, char **argv)
exit(1);
}
+ /* Get the target database name */
+ if (optind < argc)
+ dbname = argv[optind];
+ else
+ dbname = getenv("PGDATABASE");
+ if (!dbname)
+ {
+ fprintf(stderr,
+ "%s: no database name specified\n",
+ progname);
+ exit(1);
+ }
+
if (dataOnly && schemaOnly)
{
fprintf(stderr,
@@ -1022,8 +1035,6 @@ main(int argc, char **argv)
/* Let the archiver know how noisy to be */
g_fout->verbose = g_verbose;
- dbname = argv[optind];
-
/*
* Open the database using the Archiver, so it knows about it. Errors
* mean death