Re: Please make it easy to drop a database that is in use

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Evan Martin <postgresql(at)realityexists(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Please make it easy to drop a database that is in use
Date: 2012-06-21 14:07:09
Message-ID: 24795.1340287629@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Evan Martin <postgresql(at)realityexists(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2012-06-21 14:07:42 Re: Error message "psql: could not connect to server: No such file or directory"
Previous Message Albe Laurenz 2012-06-21 14:04:18 Re: Please make it easy to drop a database that is in use