Re: Strange RETURN NEXT behaviour in Postgres 8.0 - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Strange RETURN NEXT behaviour in Postgres 8.0
Date
Msg-id 26214.1108580068@sss.pgh.pa.us
Whole thread Raw
In response to Strange RETURN NEXT behaviour in Postgres 8.0  ("Sergey E. Koposov" <math@sai.msu.ru>)
Responses Re: Strange RETURN NEXT behaviour in Postgres 8.0  ("Sergey E. Koposov" <math@sai.msu.ru>)
List pgsql-hackers
"Sergey E. Koposov" <math@sai.msu.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


pgsql-hackers by date:

Previous
From: Kenneth Marshall
Date:
Subject: Re: Design notes for BufMgrLock rewrite
Next
From: "Merlin Moncure"
Date:
Subject: Re: win32 performance - fsync question