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: 20050512193248.GS23283@varlena.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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
UNION
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 www.varlena.com
(510)655-2584(o) (510)543-6079(c)
PostgreSQL Consulting, Support & Training

PostgreSQL General Bits http://www.varlena.com/GeneralBits/
==============================================================
I have always depended on the [QA] of strangers.

Responses

Browse pgsql-bugs by date

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