Re: BUG #15129: Problem with UNION/UNION ALL type setting when several NULL values before defining the proper type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, phb07(at)apra(dot)asso(dot)fr
Subject: Re: BUG #15129: Problem with UNION/UNION ALL type setting when several NULL values before defining the proper type
Date: 2018-03-25 15:43:20
Message-ID: 31859.1521992600@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
> "PG" == PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> PG> While migrating a view from another RDBMS,I reached something that
> PG> looks lie a bug in postgres.

> It's not a bug in the code, though perhaps you could point out a place
> where the documentation could be improved?

It strikes me that section 10.5 doesn't say explicitly that multiple
UNIONs are resolved pairwise. Someone who expected "x union y union z"
to be resolved holistically, like a 3-way CASE would be, is not going
to be enlightened by that section. Perhaps an additional example
using this exact situation would be helpful.

> (The SQL standard is of no particular help here since it does not allow
> NULL to appear "bare", except in contextually typed expressions.)

I think the SQL spec does offer considerable support for our pairwise
resolution approach --- nowhere does it suggest that "x union y union z"
is a construct that should be considered as a whole rather than as a
nest of two independent union operations.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2018-03-26 10:24:59 BUG #15130: outer-join-escape syntax seems not to work with latest jdbc-driver
Previous Message Andrew Gierth 2018-03-25 08:50:40 Re: BUG #15129: Problem with UNION/UNION ALL type setting when several NULL values before defining the proper type