Re: MOVE strangeness

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jeroen T(dot) Vermeulen" <jtv(at)xs4all(dot)nl>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: MOVE strangeness
Date: 2002-12-26 18:41:52
Message-ID: 200212261841.gBQIfqf27239@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> > This does not happen
> > if I replace the FETCHes by MOVEs.
>
> I'm a little confused by that remark; it seems to me that FETCH and MOVE
> have identical behaviors so far as repositioning the cursor is concerned.
> (Internally, MOVE *is* a FETCH, it just suppresses output of the rows.)
> Can you give an example where you get different behavior?

I think I see what Jeroen is saying. In this example he posted:

jtv=> begin;
BEGIN
jtv=> declare c cursor for select * from events;
DECLARE CURSOR
jtv=> fetch 3 in c;
year | event
------+------------------
2010 | A Space Oddyssey
2010 | Oddyssey Two
2038 | time_t overflow
(3 rows)

jtv=> move -3 in c;
MOVE 2

Why does the MOVE -3 return 2? If he has fetched 3, he is at the end of
the third row. If he does MOVE -3, hasn't he moved backward three rows
to the start of the first row?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-12-26 18:44:51 Re: Problems with 7.3.1
Previous Message Tom Lane 2002-12-26 18:31:50 Re: Problem with move not returning number of rows affected [was: error when using move, any suggestions?]

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2002-12-26 18:58:31 Re: MOVE strangeness
Previous Message Tom Lane 2002-12-26 18:26:11 Re: MOVE strangeness