![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
begin; declare t cursor with hold for select function() as x from R; commit; Documentation says that the rows represented by a held cursor are copied into a temporary file or memory area, but they are not, if they are results of a function call. Instead, "commit" aborts the connection. |
#3
| |||
| |||
|
|
"Gabor Berenyi" <ber_ (AT) freemail (DOT) hu> writes: begin; declare t cursor with hold for select function() as x from R; commit; Documentation says that the rows represented by a held cursor are copied into a temporary file or memory area, but they are not, if they are results of a function call. Instead, "commit" aborts the connection. Works for me. Could we see a complete, self-contained example? In particular I suppose that the details of function() might be relevant. |
#4
| |||
| |||
|
|
test=# create function crashme() returns text as 'select timeofday()' test-# language sql stable; CREATE FUNCTION test=# begin; BEGIN test=# declare t cursor with hold for select crashme() as x from pg_class; DECLARE CURSOR test=# commit; server closed the connection unexpectedly |
#5
| |||
| |||
|
|
The problem here is that CommitTransaction shuts down the trigger manager before shutting down portals, so of course trigger.c barfs when the SQL function wants it to check for queued triggers. There seems to be a rather fundamental ordering problem here, since it's certainly possible for a holdable portal to contain volatile functions that must fire triggers, and yet I suppose that a trigger might also want to use or create cursors. Perhaps we have to iterate "close holdable cursors" and "fire triggers" until there's nothing more to do. Thoughts anyone? |
#6
| |||
| |||
|
|
One further question is if it's right for the holdable portal to fire trigger at transaction commit. ISTM the non-surprising answer would be for them to fire at FETCH time. (But of course this is hard to implement, since at that time we don't have executor machinery ...) |
![]() |
| Thread Tools | |
| Display Modes | |
| |