pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6626: union all with values of type "unknown"
5+ messages / 4 participants
[nested] [flat]

* BUG #6626: union all with values of type "unknown"
@ 2012-05-04 01:01 will@heroku.com
  2012-05-22 19:41 ` Re: BUG #6626: union all with values of type "unknown" Robert Haas <robertmhaas@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: will@heroku.com @ 2012-05-04 01:01 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      6626
Logged by:          Will Leinweber
Email address:      will@heroku.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)



deik3qfhu265n6=> \x
Expanded display is on.
deik3qfhu265n6=> select version();
-[ RECORD 1
]-----------------------------------------------------------------------------------------------------------
version | PostgreSQL 9.1.3 on x86_64-unknown-linux-gnu, compiled by
gcc-4.4.real (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3, 64-bit




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #6626: union all with values of type "unknown"
  2012-05-04 01:01 BUG #6626: union all with values of type "unknown" will@heroku.com
@ 2012-05-22 19:41 ` Robert Haas <robertmhaas@gmail.com>
  2012-05-22 19:55   ` Re: BUG #6626: union all with values of type "unknown" Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Robert Haas @ 2012-05-22 19:41 UTC (permalink / raw)
  To: will@heroku.com; +Cc: pgsql-bugs

On Thu, May 3, 2012 at 9:01 PM,  <will@heroku.com> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      6626
> Logged by:          Will Leinweber
> Email address:      will@heroku.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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #6626: union all with values of type "unknown"
  2012-05-04 01:01 BUG #6626: union all with values of type "unknown" will@heroku.com
  2012-05-22 19:41 ` Re: BUG #6626: union all with values of type "unknown" Robert Haas <robertmhaas@gmail.com>
@ 2012-05-22 19:55   ` Tom Lane <tgl@sss.pgh.pa.us>
  2012-05-22 19:57     ` Re: BUG #6626: union all with values of type "unknown" Robert Haas <robertmhaas@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2012-05-22 19:55 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: will@heroku.com; pgsql-bugs

Robert Haas <robertmhaas@gmail.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.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #6626: union all with values of type "unknown"
  2012-05-04 01:01 BUG #6626: union all with values of type "unknown" will@heroku.com
  2012-05-22 19:41 ` Re: BUG #6626: union all with values of type "unknown" Robert Haas <robertmhaas@gmail.com>
  2012-05-22 19:55   ` Re: BUG #6626: union all with values of type "unknown" Tom Lane <tgl@sss.pgh.pa.us>
@ 2012-05-22 19:57     ` Robert Haas <robertmhaas@gmail.com>
  2012-05-23 03:24       ` Re: BUG #6626: union all with values of type "unknown" Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Robert Haas @ 2012-05-22 19:57 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: will@heroku.com; pgsql-bugs

On Tue, May 22, 2012 at 3:55 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@gmail.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.

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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #6626: union all with values of type "unknown"
  2012-05-04 01:01 BUG #6626: union all with values of type "unknown" will@heroku.com
  2012-05-22 19:41 ` Re: BUG #6626: union all with values of type "unknown" Robert Haas <robertmhaas@gmail.com>
  2012-05-22 19:55   ` Re: BUG #6626: union all with values of type "unknown" Tom Lane <tgl@sss.pgh.pa.us>
  2012-05-22 19:57     ` Re: BUG #6626: union all with values of type "unknown" Robert Haas <robertmhaas@gmail.com>
@ 2012-05-23 03:24       ` Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Pavel Stehule @ 2012-05-23 03:24 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; will@heroku.com; pgsql-bugs

2012/5/22 Robert Haas <robertmhaas@gmail.com>:
> On Tue, May 22, 2012 at 3:55 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Robert Haas <robertmhaas@gmail.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@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2012-05-23 03:24 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-05-04 01:01 BUG #6626: union all with values of type "unknown" will@heroku.com
2012-05-22 19:41 ` Robert Haas <robertmhaas@gmail.com>
2012-05-22 19:55   ` Tom Lane <tgl@sss.pgh.pa.us>
2012-05-22 19:57     ` Robert Haas <robertmhaas@gmail.com>
2012-05-23 03:24       ` Pavel Stehule <pavel.stehule@gmail.com>

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