From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: phb07@apra.asso.fr
Subject: BUG #15129: Problem with UNION/UNION ALL type setting when several NULL values before defining the proper type
Date: Sun, 25 Mar 2018 06:54:10 +0000
Message-ID: <152196085023.32649.9916472370480121694@wrigleys.postgresql.org> (raw)
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;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, phb07@apra.asso.fr
Subject: Re: BUG #15129: Problem with UNION/UNION ALL type setting when several NULL values before defining the proper type
In-Reply-To: <152196085023.32649.9916472370480121694@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox