pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mike Knowsley <mike.knowsley@bidorbuy.co.za>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Can not cancel a call to a function that has opened a refcursor
Date: Thu, 05 Aug 2021 11:19:09 -0400
Message-ID: <2392578.1628176749@sss.pgh.pa.us> (raw)
In-Reply-To: <97DA1097-86CD-4B05-A6BC-BF263F388F25@bidorbuy.co.za>
References: <97DA1097-86CD-4B05-A6BC-BF263F388F25@bidorbuy.co.za>

Mike Knowsley <mike.knowsley@bidorbuy.co.za> writes:
> A request to cancel a call to a function does not cancel the function if the function has opened a refcursor which it is returning.

As far as I can see, there is no such bug; you're just misunderstanding
when the query referenced by the cursor will execute.  The function
test_delay_in_refcursor() sets up the cursor and returns basically
immediately (certainly in much less than 2 seconds), so the timeout
you have in the JDBC code will never fire.  The expected pg_sleep(5)
won't execute till you try to fetch something from the refcursor.

Trying this manually in psql, I get

...
CREATE FUNCTION
regression=# \timing
Timing is on.
regression=# begin;
BEGIN
Time: 0.306 ms
regression=*# select test_delay_in_refcursor();
 test_delay_in_refcursor 
-------------------------
 <unnamed portal 1>
(1 row)

Time: 0.314 ms
regression=*# fetch from "<unnamed portal 1>";
 ?column? | pg_sleep 
----------+----------
 test     | 
(1 row)

Time: 5005.475 ms (00:05.005)

I could have canceled the FETCH (and doing so works);
but I'm way too old and slow to cancel the submillisecond
setup step.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <2392578.1628176749@sss.pgh.pa.us>
Permalink:  ../2392578.1628176749@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2392578.1628176749@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mike.knowsley@bidorbuy.co.za, pgsql-bugs@lists.postgresql.org
  Subject: Re: Can not cancel a call to a function that has opened a refcursor
  In-Reply-To: <2392578.1628176749@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox