Re: SPI cursor functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tim Keitt" <tkeitt(at)keittlab(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: SPI cursor functions
Date: 2008-10-25 00:57:17
Message-ID: 7698.1224896237@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Tim Keitt" <tkeitt(at)keittlab(dot)org> writes:
> The docs for FETCH indicate you can fetch from the current row using
> FORWARD 0, but

> SPI_scroll_cursor_fetch(someportal, FETCH_FORWARD, 0);

> fails for me. Is there a way to emulate FETCH FORWARD 0 with SPI?

Fails how? AFAICS that calls the same code that the SQL-level
FETCH command would.

You do realize that "FORWARD 0" means to re-fetch the current row,
ie the most recently fetched row? There isn't any current row in
the initial state of a cursor.

> Also, I noticed that
> SPI_scroll_cursor_move(someportal, FETCH_BACKWARD, 1);
> sets SPI_processed to 0, not 1. Is that the intended behavior?

Well, it is if you don't have any row to move backward to ...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2008-10-25 04:54:58 ERROR: cache lookup failed for function 0
Previous Message Tom Lane 2008-10-25 00:19:15 Re: Handling NULL records in plpgsql