Re: Strange RETURN NEXT behaviour in Postgres 8.0

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Strange RETURN NEXT behaviour in Postgres 8.0
Date: 2005-02-16 18:54:28
Message-ID: 26214.1108580068@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Sergey E. Koposov" <math(at)sai(dot)msu(dot)ru> writes:
> LOOP
> FETCH cur into rec;
> RETURN NEXT rec;
> EXIT WHEN NOT FOUND;
> END LOOP;
> RETURN;

Don't you think you should have the EXIT *above* the RETURN NEXT?
I would expect this to emit a bogus row of nulls after the last row
returned by the cursor. (At least that's what I get with current
sources. Pre-8.0 it might return the last row twice.)

Running it on a 500-million-row table would quite possibly run out of
memory or disk space, too, because RETURN NEXT accumulates all the
results before the function is actually exited.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2005-02-16 18:55:47 Re: win32 performance - fsync question
Previous Message Tom Lane 2005-02-16 18:08:58 Re: Help me recovering data