Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> I don't think it's particularly closely related to #4907.
Yeah. I think the real problem is that set_subqueryscan_references
is overly optimistic about how much work it has to do:
* ... Notice we do
* not do set_upper_references() here, because a SubqueryScan will
* always have been created with correct references to its subplan's
* outputs to begin with.
The upper query will have Vars with attnos that correspond to the
function's output rowtype, ie, 1,2,3,5 in this example. However the
actual output of the lower query only has 4 columns. Kinda surprising
we never hit this before, really, although I guess there are not that
many cases where a subquery could have a named rowtype.
regards, tom lane