Re: Postgresql 8.0 and Cancel/Kill backend functions

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Tony Caduto <tony(dot)caduto(at)amsoftwaredesign(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgresql 8.0 and Cancel/Kill backend functions
Date: 2005-01-12 18:42:42
Message-ID: 20050112184242.GA95593@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jan 12, 2005 at 12:00:22PM -0600, Tony Caduto wrote:

> Does anyone know if such functions have been added to version 8?

See the 8.0 Release Notes in the development documentation:

* Add function to send cancel request to other backends (Magnus)

See also the "System Administration Functions" section in the
"Functions and Operators" chapter.

Here's an example:

Session 1:
CREATE FUNCTION sleep(integer) RETURNS void AS $$
sleep $_[0];
$$ LANGUAGE plperlu;
SELECT sleep(60);

Session 2:
SELECT procpid, current_query FROM pg_stat_activity;
procpid | current_query
---------+-------------------
...
95609 | SELECT sleep(60);
...
SELECT pg_cancel_backend(95609);

Session 1:
ERROR: canceling query due to user request

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ed L. 2005-01-12 18:49:12 Re: vacuum vs open transactions
Previous Message Magnus Hagander 2005-01-12 18:22:46 Re: Postgresql 8.0 and Cancel/Kill backend functions