Re: BUG #6626: union all with values of type "unknown"

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, will(at)heroku(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6626: union all with values of type "unknown"
Date: 2012-05-23 03:24:40
Message-ID: CAFj8pRAYTgsN9pEA+a=8Pgny6rsi=QhN01GpyW-jA49oV1r_fw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

2012/5/22 Robert Haas <robertmhaas(at)gmail(dot)com>:
> On Tue, May 22, 2012 at 3:55 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>>>> deik3qfhu265n6=> with hello as (select 'hello' as name)
>>>> deik3qfhu265n6-> , bye as (select 'bye' as name)
>>>> deik3qfhu265n6-> select * from hello UNION ALL select * from bye;
>>>> ERROR:  failed to find conversion function from unknown to text
>>
>>> I think it should return a column of type text, just as if you'd done this:
>>> select v from (select 'hello' union all select 'bye') x(v);
>>
>> I don't think it's a great idea to make CTEs handle this differently
>> from other places where the same issue arises (from memory, views and
>> INSERT/SELECT have problems with unknown literals, and there are
>> probably other places I'm forgetting).
>>
>> Should we institute a uniform policy of forcing unknown sub-select
>> outputs to text type?  This would almost certainly break a few peoples'
>> queries, but the reduction of surprise might be worth it for most.
>
> I think if we can't do real type inference, forcing unknown to text is
> probably the least of evils.

can we implement late cast? Cast unknown to text only when exception
is raised, resp. before? This issue is relative unfriendly for
beginners

Regards

Pavel
>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Edmund Horner 2012-05-23 03:50:47 Re: PostgreSQL 9.2 beta1's pg_upgrade fails on Windows XP
Previous Message Maxim Boguk 2012-05-23 02:18:47 Re: BUG #6662: Database do not push condition to subquery, test case for bug 6658