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

BUG #1677: Bug in select with Union

From: "Julien Vallet" <julien(dot)vallet(at)density-tech(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1677: Bug in select with Union
Date: 2005-05-23 11:49:12
Message-ID: 20050523114912.B34B0F0B06@svr2.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      1677
Logged by:          Julien Vallet
Email address:      julien(dot)vallet(at)density-tech(dot)com
PostgreSQL version: 8.0 & 8.0.3
Operating system:   Windows XP
Description:        Bug in select with Union
Details: 

I think there is a problem with the select statement with Union.

Firstable, I create 3 tables (tuserprofileopp, tprofileopp and
tgroupprofileopp).

CREATE TABLE tuserprofileopp
(
  internalkey int8 NOT NULL,
  CONSTRAINT tuserprofileopp_pkey PRIMARY KEY (internalkey)
);

CREATE TABLE tprofileopp
(
  internalkey int8 NOT NULL,
  CONSTRAINT tprofileopp_pkey PRIMARY KEY (internalkey)
);

CREATE TABLE tgroupprofileopp
(
  internalkey int8 NOT NULL,
  manager_id int8,
  CONSTRAINT tgroupprofileopp_pkey PRIMARY KEY (internalkey)
);

Then, I write this request:
select *
from 
(
select 
internalKey, null as manager_id, 0 as clazz_ 
from TProfileOPP 
union select
internalKey, null as manager_id, 1 as clazz_ 
from TUserProfileOPP 
union select
internalKey, manager_id, 2 as clazz_ 
from TGroupProfileOPP 
) 
this_;

The result is "ERROR:  UNION types text and bigint cannot be matched"

If I do 
"select *
from 
(
select 
internalKey, null as manager_id, 0 as clazz_ 
from TProfileOPP 
union select
internalKey, manager_id, 2 as clazz_ 
from TGroupProfileOPP 
) 
this_;", It works.

Thank you.

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2005-05-23 13:54:38
Subject: Re: BUG #1677: Bug in select with Union
Previous:From: Andrew - SupernewsDate: 2005-05-23 08:18:07
Subject: Re: initdb fails on ultra2 sparc64, freebsd 5.4

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