Thanks for the updated patch. I've been reading it, but I noticed a bug in 8aba9322511f, which I thought you'd want to know to make a note of when committing this one.
So we decided in 8aba9322511f that it is okay to make the memory context in which a transient partdesc is allocated a child of PortalContext so that it disappears when the portal does. But PortalContext is apparently NULL when the planner runs, at least in the "simple" query protocol, so any transient partdescs built by the planner would effectively leak. Not good. With this patch, partdesc_nodetached is no longer transient, so the problem doesn't exist. I will write more about the updated patch in a bit... -- Amit Langote EDB: http://www.enterprisedb.com