mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Add -d/--dbname option to pg_dump.
You could already pass a database name just by passing it as the last option, without -d. This is an alias for that, like the -d/--dbname option in psql and many other client applications. For consistency.
This commit is contained in:
@ -307,6 +307,7 @@ main(int argc, char **argv)
|
||||
{"blobs", no_argument, NULL, 'b'},
|
||||
{"clean", no_argument, NULL, 'c'},
|
||||
{"create", no_argument, NULL, 'C'},
|
||||
{"dbname", required_argument, NULL, 'd'},
|
||||
{"file", required_argument, NULL, 'f'},
|
||||
{"format", required_argument, NULL, 'F'},
|
||||
{"host", required_argument, NULL, 'h'},
|
||||
@ -387,7 +388,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
while ((c = getopt_long(argc, argv, "abcCE:f:F:h:in:N:oOp:RsS:t:T:U:vwWxZ:",
|
||||
while ((c = getopt_long(argc, argv, "abcCd:E:f:F:h:iK:n:N:oOp:RsS:t:T:U:vwWxZ:",
|
||||
long_options, &optindex)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
@ -408,6 +409,10 @@ main(int argc, char **argv)
|
||||
outputCreateDB = 1;
|
||||
break;
|
||||
|
||||
case 'd': /* database name */
|
||||
dbname = pg_strdup(optarg);
|
||||
break;
|
||||
|
||||
case 'E': /* Dump encoding */
|
||||
dumpencoding = pg_strdup(optarg);
|
||||
break;
|
||||
@ -520,8 +525,11 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* Get database name from command line */
|
||||
if (optind < argc)
|
||||
/*
|
||||
* Non-option argument specifies database name as long as it wasn't
|
||||
* already specified with -d / --dbname
|
||||
*/
|
||||
if (optind < argc && dbname == NULL)
|
||||
dbname = argv[optind++];
|
||||
|
||||
/* Complain if any arguments remain */
|
||||
@ -872,6 +880,7 @@ help(const char *progname)
|
||||
" ALTER OWNER commands to set ownership\n"));
|
||||
|
||||
printf(_("\nConnection options:\n"));
|
||||
printf(_(" -d, --dbname=DBNAME database to dump\n"));
|
||||
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
|
||||
printf(_(" -p, --port=PORT database server port number\n"));
|
||||
printf(_(" -U, --username=NAME connect as specified database user\n"));
|
||||
|
Reference in New Issue
Block a user