Alvaro Herrera <alvherre@commandprompt.com> writes:
> Tom Lane wrote:
>> Having said that, this may well expose a bug in the MAX-optimization
>> code that has consequences for more useful queries. I'll take a look
>> later today if no one beats me to it.
> I refrain -- tried following it but I don't know that code at all.
I concluded that neither the planner nor the executor is doing anything
particularly wrong here. The crash comes because adding the implicit
CTID reference results in a variable with no scan referent at all, if
all the table scans have been pushed down into InitPlans by the MIN/MAX
index optimization. But there isn't any legal query variant that could
do the same thing, so I see no need to install more defenses than
disallowing the query. Which I've now done.
regards, tom lane