Re: dropdb --force

vignesh C <vignesh21@gmail.com>

From: vignesh C <vignesh21@gmail.com>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Dilip Kumar <dilipbalaut@gmail.com>, Ryan Lambert <ryan@rustprooflabs.com>, Thomas Munro <thomas.munro@gmail.com>, Anthony Nowocien <anowocien@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Filip Rembiałkowski <filip.rembialkowski@gmail.com>
Date: 2019-11-16T00:10:30Z
Lists: pgsql-hackers
On Fri, Nov 15, 2019 at 1:23 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:
>
> updated patch attached
>

Thanks Pavel  for providing updated version.
Few comments:
I felt the help text  seems incomplete:
@@ -159,6 +167,7 @@ help(const char *progname)
     printf(_("\nOptions:\n"));
     printf(_("  -e, --echo                show the commands being
sent to the server\n"));
     printf(_("  -i, --interactive         prompt before deleting anything\n"));
+    printf(_("  -f, --force               try to terminate other
connection before\n"));
     printf(_("  -V, --version             output version information,
then exit\n"));
we can change to:
printf(_("  -f, --force               try to terminate other
connection before dropping\n"));

We can add one test including -e option which validates the command
generation including WITH (FORCE):
+$node->safe_psql('postgres', 'CREATE DATABASE foobar2');
+$node->issues_sql_like(
+    [ 'dropdb', '--force', 'foobar2' ],
+    qr/statement: DROP DATABASE foobar2 WITH \(FORCE\);/,
+    'SQL DROP DATABASE (FORCE) run');
+

Also should we include one test where one session is connected to db
and another session tries dropping with -f option?

Regards,
Vignesh
EnterpriseDB: http://www.enterprisedb.com



Commits

  1. Add tests for '-f' option in dropdb utility.

  2. Move pump_until to TestLib.pm.

  3. Add the support for '-f' option in dropdb utility.

  4. Introduce the 'force' option for the Drop Database command.

  5. Improve CREATE/DROP/RENAME DATABASE so that when failing because the source