From: Tom Lane <tgl@sss.pgh.pa.us>
To: zoulx1982@163.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #11266: failed to find conversion function from unknown to bigint
Date: Tue, 26 Aug 2014 10:42:32 -0400
Message-ID: <10896.1409064152@sss.pgh.pa.us> (raw)
In-Reply-To: <20140826062110.2532.26317@wrigleys.postgresql.org>
References: <20140826062110.2532.26317@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
zoulx1982@163.com writes:
> select s.*
> from
> (select a, null b from t1
> group by a
> ) s
> union all
> select x,y from t2;--ERROR
> is there parameters to avoid the issue without changing original sql,
> or doe's somebody can fix the issue later ?
No, and no. You need to cast the NULL literal to some specific datatype
(in this example, you want the type of t2.y).
A bare NULL like this is illegal per SQL standard; you're always supposed
to cast it, or else write it in a place like an INSERT list where the
null's type can be inferred from immediate context. Most real DBMSes
allow you to violate that rule to some extent, but you should not be
surprised that the exact places where you can get away with it vary from
product to product. Postgres is not exactly like Oracle in this respect,
and we're unlikely to try to make it so.
regards, tom lane
--
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: tgl@sss.pgh.pa.us, zoulx1982@163.com
Subject: Re: BUG #11266: failed to find conversion function from unknown to bigint
In-Reply-To: <10896.1409064152@sss.pgh.pa.us>
References: <20140826062110.2532.26317@wrigleys.postgresql.org> <10896.1409064152@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