I wrote:
> That's one heck of a scary patch: nowhere in list_union's API is there
> any guarantee that it preserves list ordering, but we *must not* change
> the positions of the existing rtable entries.
Actually there's a more fundamental problem, namely that pulled-up
subqueries aren't necessarily equal() to the originals. They will
definitely be different if there were any uplevel Var references.
While you could argue that it doesn't matter because we'll only
end up redundantly checking permissions on multiple copies of the
RTEs, that's a bit beyond my threshold of ugliness...
regards, tom lane