Problem with ROWs and UNION - Mailing list pgsql-bugs

From elein@varlena.com (elein)
Subject Problem with ROWs and UNION
Date
Msg-id 20050512193248.GS23283@varlena.com
Whole thread Raw
Responses Re: Problem with ROWs and UNION
List 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@varlena.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.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Do dropdb and createdb read password from .pgpass
Next
From: Alvaro Herrera
Date:
Subject: Re: Problem with ROWs and UNION