Forum OpenACS Q&A: Response to PortalHeapMemoryFree error
"[I]t looks like this problem has already been fixed in current CVS sources --- it's a foulup in subplan handling for APPEND plans, which basically means that you need sub-SELECTS in a UNION to cause it.
Easiest patch for 7.0.* is to grab src/backend/optimizer/plan/setrefs.c
out of the CVS server or a recent nightly snapshot tarball and drop it
into 7.0.* sources as-is."