Re: [GENERAL] setof record "out" syntax and returning records

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [GENERAL] setof record "out" syntax and returning records
Date: 2008-01-21 00:48:14
Message-ID: 20080121004814.GA25201@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


This thread made me try this example. Note that there's a WARNING in the spot
where I pressed tab.

alvherre=# create or replace function foo (out pg_class) language plpgsql as $$ declare i pg_class%rowtype; begin for i in select * from pg_class loop return next; end loop; end; $$;
ERROR: cannot use RETURN NEXT in a non-SETOF function en o cerca de «next»
LINEA 1: ...begin for i in select * from pg_class loop return next; end ...
^
alvherre=# set lc_messWARNING: problem in alloc set PL/PgSQL function context: detected write past chunk end in block 0xb541d0, chunk 0xb562c0
ages to 'C';
WARNING: problem in alloc set PL/PgSQL function context: detected write past chunk en
d in block 0xb541d0, chunk 0xb562c0
SET

The reason I tried to change lc_messages is that the spanish message
struck me as a bit odd and wanted to see what the english message looked
like.

The full sequence required to create the message in a clean backend, regardless
of whether the foo(pg_class) function exists previously, is:

create function foo (out pg_class) language plpgsql as $$ declare i pg_class%type; begin for i in select * from pg_class loop return next; end loop; end; $$;
create or replace function foo (out pg_class) language plpgsql as $$ declare i pg_class%type; begin for i in select * from pg_class loop return next; end loop; end; $$;
create or replace function foo (out pg_class) language plpgsql as $$ declare i pg_class%rowtype; begin for i in select * from pg_class loop return next; end loop ; end; $$;
set lc_mess <tab>

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2008-01-21 00:52:44 Re: postgres 8.3 rc-1 ispell installation problem
Previous Message marcelo Cortez 2008-01-21 00:05:59 Re: postgres 8.3 rc-1 ispell installation problem

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-01-21 01:52:33 Re: [GENERAL] setof record "out" syntax and returning records
Previous Message Tom Lane 2008-01-20 23:41:03 Re: Friendly help for psql