Re: ERROR: MergeAppend child's targetlist doesn't match MergeAppend
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Teodor Sigaev <teodor@sigaev.ru>
Cc: Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2011-11-08T23:28:10Z
Lists: pgsql-hackers
Attachments
- draft-mergeappend-fix.patch (text/x-patch) patch
I wrote: > Not immediately sure what to do about this. The quick-and-dirty fix > would be to only apply add_child_rel_equivalences to simple inheritance > child relations, for which the added items must be Vars and must be > different (which is what that code is expecting). Seems like a bit of a > shame to lobotomize planning for UNION cases, though. Maybe we need a > more complicated representation of child EquivalenceClass members. After some thought and experimentation, the best fix seems to be to eliminate the ambiguity by wrapping subquery outputs in PlaceHolderVars whenever there is a risk of confusion. The attached crude patch fixes both test cases. It needs work (more comments and a regression test case would be good), but barring objection I'll push forward with doing it this way. regards, tom lane