Re: BUG #11266: failed to find conversion function from unknown to bigint

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: zoulx1982(at)163(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #11266: failed to find conversion function from unknown to bigint
Date: 2014-08-26 14:42:32
Message-ID: 10896.1409064152@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

zoulx1982(at)163(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Dinesh Bhandary 2014-08-26 14:44:53 Re: BUG #11264: Auto vacuum wraparound job blocking everything
Previous Message zoulx1982 2014-08-26 06:21:10 BUG #11266: failed to find conversion function from unknown to bigint