Re: pl/tcl function to detect when a request has been canceled

From: Peter Da Silva <peter(dot)dasilva(at)flightaware(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pl/tcl function to detect when a request has been canceled
Date: 2018-06-08 19:34:20
Message-ID: 91E0AE11-E371-40DE-8FE7-CBE50932D2D1@flightaware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 6/8/18, 2:21 PM, "Andres Freund" <andres(at)anarazel(dot)de> wrote:
Not sure I quite understand what you mean. You're thinking of the case
where you're processing rows one-by-one with a cursor? Or that a single
spi call takes a long while to process the query?

The former, I believe. One example (lightly obfuscated):

spi_exec -array a "SELECT this,that from table where stuff..." {
if {$use_cancel_pending && [cancel_pending]} {
error "cancelled in ..."
}
do_something_with_array a
more_business_code_here
and_so_on...
}

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Steve Atkins 2018-06-08 20:34:19 Compromised postgresql instances
Previous Message Tom Lane 2018-06-08 19:23:18 Re: pl/tcl function to detect when a request has been canceled