The previous fix in CVS HEAD and 8.4 for handling the case where a cursor

Heikki Linnakangas <heikki.linnakangas@iki.fi>

Commit: 97f29c865f4332d48465735b22a42d9b0deacd12
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: 2010-07-05T09:27:57Z
Releases: 7.4.30
The previous fix in CVS HEAD and 8.4 for handling the case where a cursor
being used in a PL/pgSQL FOR loop is closed was inadequate, as Tom Lane
pointed out. The bug affects FOR statement variants too, because you can
close an implicitly created cursor too by guessing the "<unnamed portal X>"
name created for it.

To fix that, "pin" the portal to prevent it from being dropped while it's
being used in a PL/pgSQL FOR loop. Backpatch all the way to 7.4 which is
the oldest supported version.

Files

PathChange+/−
src/backend/utils/mmgr/portalmem.c modified +40 −4
src/include/utils/portal.h modified +4 −1
src/pl/plpgsql/src/pl_exec.c modified +14 −2