7.3: Change in cursor behaviour?

Started by Jeroen T. Vermeulenabout 23 years ago3 messages

I've been getting reports of one of my test scenarios for libpqxx
failing with postgres 7.3. At the moment I can't reproduce this (I'm
still on 7.2) and I can't find anything pertinent in CVS commit
messages, mailing lists etc. so I'd really appreciate any lucidity from
this list.

My problem appears to be related to moving a cursor backwards beyond its
point of origin. I realize this is a tacky thing to do, but I sort of
got the impression that moving backwards by some number larger than the
current position would be equivalent to MOVE BACKWARD ALL. Which makes
my code a hell of a lot simpler. It makes a good portion of my life a
hell of a lot simpler, come to think of it, so I'd really appreciate
having this property in the future.

The scenario boils down to: Create a cursor, fetch n rows, move minus 2
billion or so rows, fetch 1 row. That last fetch used to give me the
row I was hoping for (the original first row again), but with 7.3 it
appears to yield nothing.

Is this intentional? Should I change my code? Have I been a bad boy?

Jeroen

#2Rod Taylor
rbt@rbt.ca
In reply to: Jeroen T. Vermeulen (#1)
Re: 7.3: Change in cursor behaviour?

On Mon, 2002-12-02 at 10:20, Jeroen T. Vermeulen wrote:

The scenario boils down to: Create a cursor, fetch n rows, move minus 2
billion or so rows, fetch 1 row. That last fetch used to give me the
row I was hoping for (the original first row again), but with 7.3 it
appears to yield nothing.

Seems to work the fine for me:

rbt=# select version();
version
------------------------------------------------------------------------
PostgreSQL 7.4devel on i386-unknown-freebsd4.7, compiled by GCC 2.95.4
(1 row)

rbt=# begin;
BEGIN
rbt=# declare c cursor for select * from pg_attribute;
DECLARE CURSOR
rbt=# fetch 5 from c;
attrelid | attname | atttypid | attstattarget | attlen | attnum |
attndims | attcacheoff | atttypmod | attbyval | attstorage | attisset |
attalign | attnotnull | atthasdef | attisdropped | attislocal |
attinhcount
----------+--------------+----------+---------------+--------+--------+----------+-------------+-----------+----------+------------+----------+----------+------------+-----------+--------------+------------+-------------
1247 | typname | 19 | -1 | 64 | 1
| 0 | -1 | -1 | f | p | f
| i | t | f | f | t
| 0
1247 | typnamespace | 26 | -1 | 4 | 2
| 0 | -1 | -1 | t | p | f
| i | t | f | f | t
| 0
1247 | typowner | 23 | 0 | 4 | 3
| 0 | -1 | -1 | t | p | f
| i | t | f | f | t
| 0
1247 | typlen | 21 | 0 | 2 | 4
| 0 | -1 | -1 | t | p | f
| s | t | f | f | t
| 0
1247 | typbyval | 16 | 0 | 1 | 5
| 0 | -1 | -1 | t | p | f
| c | t | f | f | t
| 0
(5 rows)

rbt=# move -15 in c;
MOVE 4
rbt=# fetch 1 from c;
attrelid | attname | atttypid | attstattarget | attlen | attnum |
attndims | attcacheoff | atttypmod | attbyval | attstorage | attisset |
attalign | attnotnull | atthasdef | attisdropped | attislocal |
attinhcount
----------+---------+----------+---------------+--------+--------+----------+-------------+-----------+----------+------------+----------+----------+------------+-----------+--------------+------------+-------------
1247 | typname | 19 | -1 | 64 | 1
| 0 | -1 | -1 | f | p | f
| i | t | f | f | t
| 0
(1 row)

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

In reply to: Rod Taylor (#2)
Re: 7.3: Change in cursor behaviour?

On Mon, Dec 02, 2002 at 02:29:03PM -0500, Rod Taylor wrote:

Seems to work the fine for me:

Puzzling...

Would you mind, if you have time, downloading libpqxx from GBorg and
doing a ./configure; make; make check and telling me if tests 19 & 38
succeed? I expect them to have identical results, so you're likely to
see either two failures or none. Be aware that the test run will add
two tables, events and orgevents to your default database and delete
any contents found in them.

Download is at

http://gborg.postgresql.org/project/libpqxx/download/download.php

and direct URL for the source tarball is

ftp://gborg.postgresql.org/pub/libpqxx/stable/libpqxx-1.1.4.tar.gz

TIA!

Jeroen