Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group