tags:

views:

1098

answers:

2

Is there a way to force clients to disconnect from PostgreSQL? I'm looking for the equivlent of DB2's force application all.

I'd like to do this on my development box because when I've got database consoles open, I can't load a database dump. I have to quit them first.

+1  A: 

I found this thread on the mailing list. It suggests using SIGTERM to cause the clients to disconnect.

Not as clean as db2 force application all.

Luke Francl
+1  A: 

Combine pg_terminate_backend function and the pg_stat_activity system view.

Milen A. Radev
pg_cancel_backend() doesn't disconnect, it only cancels the current query. Next query can come in any second using the same old connection that is still there.
Frank Heikens
Fixed. Thank you!
Milen A. Radev