Re: BUG #11266: failed to find conversion function from unknown to bigint - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #11266: failed to find conversion function from unknown to bigint
Date
Msg-id 10896.1409064152@sss.pgh.pa.us
Whole thread Raw
In response to BUG #11266: failed to find conversion function from unknown to bigint  (zoulx1982@163.com)
List pgsql-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

pgsql-bugs by date:

Previous
From: zoulx1982@163.com
Date:
Subject: BUG #11266: failed to find conversion function from unknown to bigint
Next
From: Kevin Grittner
Date:
Subject: Re: BUG #11208: Refresh Materialized View Concurrently bug using user Postgres