I wrote:
> It looks like the problem is we're building a MergeAppend plan and not
> getting the targetlist for the MergeAppend node right.
Found it --- simple oversight in building optimized min/max plans.
If you need a patch now, see
http://git.postgresql.org/gitweb/?p=postgresql.git;a=patch;h=5d0731da521f090f80ea39529fe274ac6d6bffa1
regards, tom lane