Re: dropdb --force
Pavel Stehule <pavel.stehule@gmail.com>
From: Pavel Stehule <pavel.stehule@gmail.com>
To: vignesh C <vignesh21@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-18T05:02:44Z
Lists: pgsql-hackers
po 18. 11. 2019 v 4:43 odesílatel vignesh C <vignesh21@gmail.com> napsal:
> On Sat, Nov 16, 2019 at 1:25 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"));
> >>
> >
> > done. maybe alternative can be "first try to terminate other
> connections". It is shorter. The current text has 78 chars, what should be
> acceptable
> >
> >>
> >> 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');
> >> +
> >
> >
> > I don't understand to this point. It is effectively same like existing
> test
> >
>
> When we don't specify -e option, the query used to drop db will not be
> printed like below:
> ./dropdb testdb1
> When we specify -e option, the query used to drop db will be printed like
> below:
> ./dropdb -e testdb2
> SELECT pg_catalog.set_config('search_path', '', false);
> DROP DATABASE testdb2;
> If we specify -e option, the query that is being used to drop db will
> be printed. In the existing test I could not see the inclusion of -e
> option. I was thinking to add a test including -e that way the query
> that includes force option gets validated.
>
still I don't understand. The created query is tested already by current
test.
Do you want to test just -e option? Then it should be done as separate
issue. Do this now is little bit messy.
> >>
> >> Also should we include one test where one session is connected to db
> >> and another session tries dropping with -f option?
> >
> >
> > I afraid so test API doesn't allow asynchronous operations. Do you have
> any idea, how to it?
> >
>
> I had seen that isolation test(src/test/isolation) has a framework to
> support this. You can have a look to see if it can be handled using
> that.
>
I'll look there
> Regards,
> Vignesh
> EnterpriseDB: http://www.enterprisedb.com
>
Commits
-
Add tests for '-f' option in dropdb utility.
- 8a7e9e9dad56 13.0 landed
-
Move pump_until to TestLib.pm.
- 290acac92b1d 13.0 landed
-
Add the support for '-f' option in dropdb utility.
- 80e05a088e4e 13.0 landed
-
Introduce the 'force' option for the Drop Database command.
- 1379fd537f9f 13.0 landed
-
Improve CREATE/DROP/RENAME DATABASE so that when failing because the source
- 4abd7b49f1e9 8.4.0 cited