I wrote:
> Poking around a bit, it seems like this is a thinko in HoldPinnedPortals:
> it's not considering the possibility of a failure during HoldPortal().
> In your test the failure is triggered by query cancel, but an ordinary
> execution error while finishing out a cursor's calculations would be
> a problem too.
Pursuant to which observation, here's a fully self-contained test case.
regards, tom lane
CREATE PROCEDURE crashme()
LANGUAGE plpgsql
AS $procedure$
DECLARE id_ int;
BEGIN
FOR id_ IN SELECT 1/(x-1000) from GENERATE_SERIES(1,1000) x LOOP
COMMIT;
END LOOP;
END;
$procedure$;
call crashme();