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

2018-06-08 Thread Peter Da Silva
On 6/8/18, 2:21 PM, "Andres Freund" 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

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

2018-06-08 Thread Tom Lane
Andres Freund writes: > Either way, I'm not convinced that handling query cancels in isolation > is really the right thing. I think pretty much all forms of interrupt > would need to be processed, not just cancels. +1 regards, tom lane

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

2018-06-08 Thread Andres Freund
On 2018-06-08 19:16:49 +, Peter Da Silva wrote: > On 6/8/18, 1:12 PM, "Andres Freund" wrote: > I'm not terribly opposed to this, but I wonder if the much more > pragmatic solution is to just occasionally call a database function that > checks this? You could just run SELECT 1

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

2018-06-08 Thread Peter Da Silva
On 6/8/18, 1:12 PM, "Andres Freund" wrote: I'm not terribly opposed to this, but I wonder if the much more pragmatic solution is to just occasionally call a database function that checks this? You could just run SELECT 1 occasionally :/ After further discussion with our team: Would

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

2018-06-08 Thread Andres Freund
On 2018-06-08 14:41:41 -0400, Tom Lane wrote: > Andres Freund writes: > > On 2018-06-08 18:08:14 +, Peter Da Silva wrote: > >> There is a C-level variable QueryCancelPending that can be used to > >> monitor for this case, but it’s not visible at the pl/tcl scripting > >> level. This is a

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

2018-06-08 Thread Peter Da Silva
On 6/8/18, 1:12 PM, "Andres Freund" wrote: I'm not terribly opposed to this, but I wonder if the much more pragmatic solution is to just occasionally call a database function that checks this? You could just run SELECT 1 occasionally :/ That seems to work, and I suppose in most

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

2018-06-08 Thread Tom Lane
Andres Freund writes: > On 2018-06-08 18:08:14 +, Peter Da Silva wrote: >> There is a C-level variable QueryCancelPending that can be used to >> monitor for this case, but it’s not visible at the pl/tcl scripting >> level. This is a simple new command that returns the current state of >> this

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

2018-06-08 Thread Andres Freund
Hi, On 2018-06-08 18:08:14 +, Peter Da Silva wrote: > We have occasional need to run very long-running pl/tcl scripts. If > the request is cancelled (say, by the user hitting ^c in psql) the > server-side script still runs to completion. > > There is a C-level variable QueryCancelPending

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

2018-06-08 Thread Peter Da Silva
We have occasional need to run very long-running pl/tcl scripts. If the request is cancelled (say, by the user hitting ^c in psql) the server-side script still runs to completion. There is a C-level variable QueryCancelPending that can be used to monitor for this case, but it’s not visible at