The previous fix in CVS HEAD and 8.4 for handling the case where a cursor
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 5 Jul 2010 09:27:31 +0000 (09:27 +0000)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 5 Jul 2010 09:27:31 +0000 (09:27 +0000)
commit823459706511eab1dd17966a6774f288f0613985
treec1af23ee12777959a21d8ee07e82ead638246757
parent1a0dd89da41ff619d763500961df1d7b0e9629d2
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.
src/backend/utils/mmgr/portalmem.c
src/include/utils/portal.h
src/pl/plpgsql/src/pl_exec.c