Re: Postgresql 8.0 and Cancel/Kill backend functions - Mailing list pgsql-general

From Michael Fuhr
Subject Re: Postgresql 8.0 and Cancel/Kill backend functions
Date
Msg-id 20050112184242.GA95593@winnie.fuhr.org
Whole thread Raw
In response to Postgresql 8.0 and Cancel/Kill backend functions  (Tony Caduto <tony.caduto@amsoftwaredesign.com>)
List 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/

pgsql-general by date:

Previous
From: "Magnus Hagander"
Date:
Subject: Re: Postgresql 8.0 and Cancel/Kill backend functions
Next
From: "Ed L."
Date:
Subject: Re: vacuum vs open transactions