diff --git a/doc/src/sgml/ref/dropdb.sgml b/doc/src/sgml/ref/dropdb.sgml
index e20bcdb..2092bb6 100644
*** a/doc/src/sgml/ref/dropdb.sgml
--- b/doc/src/sgml/ref/dropdb.sgml
*************** PostgreSQL documentation
*** 87,92 ****
--- 87,102 ----
+
+
+
+
+ Don't report an error if the specified database does not exist.
+
+
+
+
+
diff --git a/doc/src/sgml/ref/dropuser.sgml b/doc/src/sgml/ref/dropuser.sgml
index c158103..22580a4 100644
*** a/doc/src/sgml/ref/dropuser.sgml
--- b/doc/src/sgml/ref/dropuser.sgml
*************** PostgreSQL documentation
*** 89,94 ****
--- 89,104 ----
+
+
+
+
+ Don't report an error if the specified user does not exist.
+
+
+
+
+
diff --git a/src/bin/scripts/dropdb.c b/src/bin/scripts/dropdb.c
index 4cec63e..187bf6c 100644
*** a/src/bin/scripts/dropdb.c
--- b/src/bin/scripts/dropdb.c
*************** main(int argc, char *argv[])
*** 29,34 ****
--- 29,35 ----
{"password", no_argument, NULL, 'W'},
{"echo", no_argument, NULL, 'e'},
{"interactive", no_argument, NULL, 'i'},
+ {"if-exists", no_argument, NULL, 'X'},
{NULL, 0, NULL, 0}
};
*************** main(int argc, char *argv[])
*** 43,48 ****
--- 44,50 ----
enum trivalue prompt_password = TRI_DEFAULT;
bool echo = false;
bool interactive = false;
+ bool if_exists = false;
PQExpBufferData sql;
*************** main(int argc, char *argv[])
*** 54,60 ****
handle_help_version_opts(argc, argv, "dropdb", help);
! while ((c = getopt_long(argc, argv, "h:p:U:wWei", long_options, &optindex)) != -1)
{
switch (c)
{
--- 56,62 ----
handle_help_version_opts(argc, argv, "dropdb", help);
! while ((c = getopt_long(argc, argv, "h:p:U:wWeiX", long_options, &optindex)) != -1)
{
switch (c)
{
*************** main(int argc, char *argv[])
*** 79,84 ****
--- 81,89 ----
case 'i':
interactive = true;
break;
+ case 'X':
+ if_exists = true;
+ break;
default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
*************** main(int argc, char *argv[])
*** 110,117 ****
initPQExpBuffer(&sql);
! appendPQExpBuffer(&sql, "DROP DATABASE %s;\n",
! fmtId(dbname));
/*
* Connect to the 'postgres' database by default, except have the
--- 115,122 ----
initPQExpBuffer(&sql);
! appendPQExpBuffer(&sql, "DROP DATABASE %s%s;\n",
! (if_exists ? "IF EXISTS " : ""), fmtId(dbname));
/*
* Connect to the 'postgres' database by default, except have the
*************** help(const char *progname)
*** 146,151 ****
--- 151,157 ----
printf(_("\nOptions:\n"));
printf(_(" -e, --echo show the commands being sent to the server\n"));
printf(_(" -i, --interactive prompt before deleting anything\n"));
+ printf(_(" -X, --if-exists don't report error if database doesn't exist\n"));
printf(_(" --help show this help, then exit\n"));
printf(_(" --version output version information, then exit\n"));
printf(_("\nConnection options:\n"));
diff --git a/src/bin/scripts/dropuser.c b/src/bin/scripts/dropuser.c
index 0949a5e..bf5196f 100644
*** a/src/bin/scripts/dropuser.c
--- b/src/bin/scripts/dropuser.c
*************** main(int argc, char *argv[])
*** 29,34 ****
--- 29,35 ----
{"password", no_argument, NULL, 'W'},
{"echo", no_argument, NULL, 'e'},
{"interactive", no_argument, NULL, 'i'},
+ {"if-exists", no_argument, NULL, 'X'},
{NULL, 0, NULL, 0}
};
*************** main(int argc, char *argv[])
*** 43,48 ****
--- 44,50 ----
enum trivalue prompt_password = TRI_DEFAULT;
bool echo = false;
bool interactive = false;
+ bool if_exists = false;
PQExpBufferData sql;
*************** main(int argc, char *argv[])
*** 54,60 ****
handle_help_version_opts(argc, argv, "dropuser", help);
! while ((c = getopt_long(argc, argv, "h:p:U:wWei", long_options, &optindex)) != -1)
{
switch (c)
{
--- 56,62 ----
handle_help_version_opts(argc, argv, "dropuser", help);
! while ((c = getopt_long(argc, argv, "h:p:U:wWeiX", long_options, &optindex)) != -1)
{
switch (c)
{
*************** main(int argc, char *argv[])
*** 79,84 ****
--- 81,89 ----
case 'i':
interactive = true;
break;
+ case 'X':
+ if_exists = true;
+ break;
default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
*************** main(int argc, char *argv[])
*** 110,116 ****
}
initPQExpBuffer(&sql);
! appendPQExpBuffer(&sql, "DROP ROLE %s;\n", fmtId(dropuser));
conn = connectDatabase("postgres", host, port, username, prompt_password, progname);
--- 115,122 ----
}
initPQExpBuffer(&sql);
! appendPQExpBuffer(&sql, "DROP ROLE %s%s;\n",
! (if_exists ? "IF EXISTS " : ""), fmtId(dropuser));
conn = connectDatabase("postgres", host, port, username, prompt_password, progname);
*************** help(const char *progname)
*** 141,146 ****
--- 147,153 ----
printf(_("\nOptions:\n"));
printf(_(" -e, --echo show the commands being sent to the server\n"));
printf(_(" -i, --interactive prompt before deleting anything\n"));
+ printf(_(" -X, --if-exists don't report error if user doesn't exist\n"));
printf(_(" --help show this help, then exit\n"));
printf(_(" --version output version information, then exit\n"));
printf(_("\nConnection options:\n"));