Re: Can not cancel a call to a function that has opened a refcursor - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Can not cancel a call to a function that has opened a refcursor
Date
Msg-id 2392578.1628176749@sss.pgh.pa.us
Whole thread Raw
In response to Can not cancel a call to a function that has opened a refcursor  (Mike Knowsley <mike.knowsley@bidorbuy.co.za>)
Responses Re: Can not cancel a call to a function that has opened a refcursor
Re: Can not cancel a call to a function that has opened a refcursor
List pgsql-bugs
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
isreturning. 

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



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #17135: duplicate key value violates unique constraint
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #17134: pg_restore ERROR: operator does not exist: util.ltree = util.ltree