Обсуждение: cursor bug

Поиск
Список
Период
Сортировка

cursor bug

От
Дата:
Hi. I sent this bug to the bugs mailing list. But the email never turned
up on the list. Could somebody here tell me what I'm doing wrong, and why
the email won't show up? Am I breaking some unwritten rule of the bugs
list? I would really like to see an answer to this.

Thanks a lot!

-w

---
washingtonirving@yahoo.com wrote:

============================================================================
                         POSTGRESQL BUG REPORT TEMPLATE

============================================================================
Your name       : washington irving
Your email address  : washingtonirving@yahoo.com


System Configuration---------------------
  Architecture (example: Intel Pentium)     : Intel
Pentium/powerpc-apple-darwin6.6

  Operating System (example: Linux 2.0.26 ELF)  :Linux 2.4.18 ELF,
FreeBSD 4.8 Release, Mac OSX 10.2.6

  PostgreSQL version (example: PostgreSQL-7.3.4):   PostgreSQL-7.3.4,
7.3.3

  Compiler used (example:  gcc 2.95.2)      :gcc3.1, gcc 3.3.1, gcc 2.95.4


Please enter a FULL description of your problem:
------------------------------------------------
Under some cases, using cursors and the fetch and move commands don't
work as expected. Please see below for a full decription of the
problem
with the attached dump.



Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

I'm attaching the dump of a database named test. I've managed to
reproduce this bug on freebsd (postgresql 7.3.3), linux (7.3.3) and
mac osx
(both 7.3.3. and 7.3.4). This is the smallest test case I could come
up
with. In this test, I first declare a cursor and
then try to fetch 10k rows. It returns 2153 rows (the number of rowsthat
satisfy the select). Then I try to fetch another 10k rows. This
returns an empty list (as it should). Then I try to move the cursor
back by 2153. This does not move the cursor at all. This happens
regardless of the number you use in the fetch command (for instance
fetching 1000 rows at a time). It also happens regardless of the
number
passed in to the move command.

Either this is a bug, or I'm doing something terribly wrong. Could
people who know more about this please look into it.


-- psql session showing problem --
unix prompt> psql test
Welcome to psql 7.3.3, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

test=# begin;
BEGINtest=# declare c cursor for SELECT * from  pa,  ua where ua.adid =
pa.adid
and pa.pid = 1;
DECLARE CURSOR
test=# fetch 10000 from c;
.... 2153 rows returned ....
test=# fetch 10000 from c;
 pid | adid | cid | k | c | u | ad | adid
(0 rows)
test=# move -2153 from c;
MOVE 0
test=# fetch 10000 from c; pid | adid | cid | k | c | u | ad | adid
-----+------+-----+---+---+---+----+------
(0 rows)

test=#




If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: cursor bug

От
Tom Lane
Дата:
<washingtonirving@yahoo.com> writes:
> Under some cases, using cursors and the fetch and move commands don't
> work as expected.

Moving backwards in complex queries (anything more complex than a single
table scan) doesn't work reliably in releases before 7.4.  In 7.4 you
can do it, but you'll usually have to specifically declare the cursor
as SCROLL ... and eat the ensuing overhead ...

            regards, tom lane

Re: cursor bug

От
Дата:
Thanks for the quick reply. Couple questions:
- when is 7.4 expected?
- what is the overhead in declaring a cursor scroll? time? space?

thanks
-w

--- Tom Lane <tgl@sss.pgh.pa.us> wrote:
> <washingtonirving@yahoo.com> writes:
> > Under some cases, using cursors and the fetch and move commands don't
> > work as expected.
>
> Moving backwards in complex queries (anything more complex than a single
> table scan) doesn't work reliably in releases before 7.4.  In 7.4 you
> can do it, but you'll usually have to specifically declare the cursor
> as SCROLL ... and eat the ensuing overhead ...
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings


=====
http://www.kurukshetra.org
Discuss news and opinions on India.

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com