From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: stephan@teeuwendesign.nl <stephan@teeuwendesign.nl>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #16396: Parallel Union queries seem to treat NULL values differently
Date: Mon, 27 Apr 2020 12:40:52 -0400
Message-ID: <22034.1588005652@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwaxA6SKbvnn7A70O6RSPBtaQ_ym=6FDHpbKYSX=KYGfUA@mail.gmail.com>
References: <16396-083a432fe7ac8fb9@postgresql.org>
<CAKFQuwaxA6SKbvnn7A70O6RSPBtaQ_ym=6FDHpbKYSX=KYGfUA@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Monday, April 27, 2020, PG Bug reporting form <noreply@postgresql.org>
> wrote:
>> But as in our query the following happened:
>> SELECT hello_world
>> FROM (SELECT CAST(NULL AS INTEGER) AS hello_world) as a
>> UNION
>> SELECT hello_world
>> FROM (SELECT NULL AS hello_world) as b
>> It fails and is only fixable by defining the NULL in the right side of the
>> UNION as CAST(NULL AS INTEGER.
> In the example the second null is untyped still when it gets fed to the
> used and so can be implicitly cast to match the left side of the union. In
> you real case the null appears in a subquery under the from clause and
> needs to be made into an actual type before it can be passed out of the
> subquery and appear in the main query. The resultant type here is text.
> Then the union happens and integer and text cannot be melded together.
Yeah. I believe this changed in v10, at this commit:
https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=1e7c4bb0049732ece651d993d...
Probably that should have been called out as an incompatibility in the
v10 release notes, but I don't immediately see anything there that
matches. In any case, it's intentional.
regards, tom lane
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: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, stephan@teeuwendesign.nl, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16396: Parallel Union queries seem to treat NULL values differently
In-Reply-To: <22034.1588005652@sss.pgh.pa.us>
* 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