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)


=============================================================
[EMAIL PROTECTED]        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.


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

Reply via email to