On Fri, Jun 14, 2019 at 5:19 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> I took a closer look at the code to refresh my memory about this,
> and the actual rule for recursive unions is that the output of
> the union has to have the same column types/collations that were
> inferred from the non-recursive (first) side alone. This is needed
> because when we do parse analysis of the recursive side, those
> types/collations are what we'll assume for any references to the
> recursive union's result. It's too late to change those decisions
> when we find out what the UNION actually produces.
Thanks for taking time and effort to explain this really interesting
piece of code.
> Obviously there's more than one way you could fix the mismatch, but
> I think that changing the NULL to type "name" is the nicest.
I've fixed the query both on the post and in my repository, thanks.
Thanks also to Sebastien for pointing out my error.
Luca