The following bug has been logged on the website:
Bug reference: 15129
Logged by: Philippe BEAUDOIN
Email address: phb07@apra.asso.fr
PostgreSQL version: 10.3
Operating system: linux
Description:
While migrating a view from another RDBMS,I reached something that looks lie
a bug in postgres.
It concerns all supported postgres versions.
After a lot of simplification steps, I have a very simple test case that
reproduces the issue.
-- This statement works as expected: the type of the result column is
determined by the type of the first not null value
SELECT NULL
UNION
SELECT 1::INT;
-- But with an additional NULL value, the statement fails with a message:
"UNION types text and integer cannot be matched"
SELECT NULL
UNION
SELECT NULL
UNION
SELECT 1::INT;
-- Adding an explicit cast on the first occurrence fixes the issue (I used
this trick as a workaround)
SELECT NULL::INT
UNION
SELECT NULL
UNION
SELECT 1::INT;