Re: Please make it easy to drop a database that is in use - Mailing list pgsql-general

From Tom Lane
Subject Re: Please make it easy to drop a database that is in use
Date
Msg-id 24795.1340287629@sss.pgh.pa.us
Whole thread Raw
In response to Re: Please make it easy to drop a database that is in use  (Evan Martin <postgresql@realityexists.net>)
Responses Re: Please make it easy to drop a database that is in use  (Evan Martin <postgresql@realityexists.net>)
List pgsql-general
Evan Martin <postgresql@realityexists.net> writes:
> That's a fair point, so perhaps DROP DATABASE should still fail if the
> /current/ connection is to that database (preferably with a helpful
> error like "you cannot drop the database you are connected to").

It does that.

> SELECT pg_terminate_backend(procpid)
> FROM pg_stat_activity
> WHERE datname = 'dropme';
> ERROR:  must be superuser to signal other server processes

As far as that goes, there's a pending patch to reduce the privileges
required to use pg_terminate_backend.  I'm not in favor of having DROP
DATABASE do it for you though --- that just seems like a very
large-caliber foot gun.

            regards, tom lane

pgsql-general by date:

Previous
From: "Albe Laurenz"
Date:
Subject: Re: Please make it easy to drop a database that is in use
Next
From: Adrian Klaver
Date:
Subject: Re: Error message "psql: could not connect to server: No such file or directory"