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

Problem with ROWs and UNION

From: elein(at)varlena(dot)com (elein)
To: pgsql-bugs(at)postgresql(dot)org
Cc: elein <elein(at)varlena(dot)com>
Subject: Problem with ROWs and UNION
Date: 2005-05-12 19:32:48
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Problem with ROW types in UNION.

1. UNION of ROW types fails with operator error.

create type addrs as (
	addr text,
	city	text,
	state	char(2),
	zip	text);

-- UNION of ROWS doesn't work (simply wrong)
select ROW('4514 Cherry St','Oakland','CA','94666')::addrs
select ROW('4515 Cherry St','Oakland','CA','94666')::addrs;
-- ERROR:  could not identify an ordering operator for type addrs
-- HINT:  Use an explicit ordering operator or modify the query.

-- But select * containing rows does work.
create table people (
	name	text,
	fname	text,
	addr	addrs
insert into people values ('ae','aem',ROW('4514 Cherry St','Oakland','CA','94666') );
insert into people values ('go','ggo',ROW('4515 Cherry St','Oakland','CA','94666') );

select * from people;
 name | fname |                addr
 ae   | aem   | ("4514 Cherry St",Oakland,CA,94666)
 go   | ggo   | ("4515 Cherry St",Oakland,CA,94666)
(2 rows)

elein(at)varlena(dot)com        Varlena, LLC
(510)655-2584(o)                             (510)543-6079(c)
          PostgreSQL Consulting, Support & Training   

PostgreSQL General Bits
I have always depended on the [QA] of strangers.


pgsql-bugs by date

Next:From: Alvaro HerreraDate: 2005-05-12 19:57:18
Subject: Re: Problem with ROWs and UNION
Previous:From: alon zviDate: 2005-05-12 16:46:42
Subject: BUG #1666: problem install on amd athlon 64 machine

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