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