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 ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq