why can't plpgsql return a row-expression? - Mailing list pgsql-hackers

From Robert Haas
Subject why can't plpgsql return a row-expression?
Date
Msg-id CA+TgmoZKsw_13+zBqO3QmncK=kp+7-sWuv6NsMr7Z2K_wMW52Q@mail.gmail.com
Whole thread Raw
Responses Re: why can't plpgsql return a row-expression?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

PL/pgsql seems to have a strange restriction regarding "RETURN".
Normally, you can write "RETURN <expression>".  But if the function
returns a row type, then you can only write "RETURN variable" or
"RETURN NULL".

rhaas=# create type xyz as (a int, b int);
CREATE TYPE
rhaas=# select row(1,2)::xyz; row
-------(1,2)
(1 row)

rhaas=# create or replace function return_xyz() returns xyz as $$
rhaas$# begin
rhaas$#     return row(1,2)::xyz;
rhaas$# end$$ language plpgsql;
ERROR:  RETURN must specify a record or row variable in function returning row
LINE 3:     return row(1,2)::xyz;                  ^

Off the top of my head, I can't think of any reason for this
restriction, nor can I find any code comments or anything in the
commit log which explains the reason for it.  Does anyone know why we
don't allow this?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Missing OID define
Next
From: Amit Kapila
Date:
Subject: Re: [BUGS] BUG #7534: walreceiver takes long time to detect n/w breakdown