From: Vik Fearing <vik.fearing@dalibo.com>
To: jp.deplaix@gmail.com
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #8696: Type-checking seems to fail on UNIONs with arrays
Date: Mon, 23 Dec 2013 02:21:48 +0100
Message-ID: <52B7902C.5050405@dalibo.com> (raw)
In-Reply-To: <E1Vutfw-00071Q-UX@wrigleys.postgresql.org>
References: <E1Vutfw-00071Q-UX@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 12/23/2013 01:47 AM, jp.deplaix@gmail.com wrote:
> (SELECT NULL AS test)
> UNION
> (SELECT NULL AS test)
> UNION
> (SELECT array_agg(t.name) AS test FROM foo AS t)
> ;
>
>
> fails with:
> ERROR: UNION types text and text[] cannot be matched
>
>
> Is it (as I suppose) a bug or a well known limitation ?
It's a well known limitation (I knew what was coming before I read it),
but I can't seem to find the right keywords to dig up a reference about
it at the moment.
It has nothing to do with arrays, but the fact that you have *two*
unknown types before a known one.
To wit:
vik=# select null union select null union select 1;
ERROR: UNION types text and integer cannot be matched
LINE 1: select null union select null union select 1;
The workaround is to provide the type in either the first or second
union-ed query:
vik=# select null::integer union select null union select 1;
int4
----
1
(2 rows)
vik=# select null union select null::integer union select 1;
?column?
--------
1
(2 rows)
PS: Interesting that the column name changed with those two queries...
--
Vik
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: vik.fearing@dalibo.com, jp.deplaix@gmail.com
Subject: Re: BUG #8696: Type-checking seems to fail on UNIONs with arrays
In-Reply-To: <52B7902C.5050405@dalibo.com>
References: <E1Vutfw-00071Q-UX@wrigleys.postgresql.org> <52B7902C.5050405@dalibo.com>
* 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