Skip site navigation (1) Skip section navigation (2)

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

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: will(at)heroku(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6626: union all with values of type "unknown"
Date: 2012-05-22 19:41:00
Message-ID: CA+TgmoZgbsVsjDNxGbp9w1AmPMWz0G72ccCcckPdMM6251uuCA@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-bugs
On Thu, May 3, 2012 at 9:01 PM,  <will(at)heroku(dot)com> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      6626
> Logged by:          Will Leinweber
> Email address:      will(at)heroku(dot)com
> PostgreSQL version: 9.1.3
> Operating system:   ubuntu 10.04
> Description:
>
> This was surprising because it worked without the UNION ALL. Casting to text
> fixes the problem. It seems that this should a column of type unknown.
>
> deik3qfhu265n6=> with hello as (select 'hello' as name)
> , bye as (select 'bye' as name)
> select * from hello;
>  name
> -------
>  hello
> (1 row)
>
> 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
>
>
> deik3qfhu265n6=> with hello as (select 'hello'::text as name)
> deik3qfhu265n6-> , bye as (select 'bye'::text as name)
> deik3qfhu265n6-> select * from hello UNION ALL select * from bye;
>  name
> -------
>  hello
>  bye
> (2 rows)

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);

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

pgsql-bugs by date

Next:From: Robert HaasDate: 2012-05-22 19:46:26
Subject: Re: BUG #6637: Casablanca timezone is wrong
Previous:From: Robert HaasDate: 2012-05-22 19:36:22
Subject: Re: BUG #6625: not sufficient privileges to start system service

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group