bug: HashJoin and backward cursors... - Mailing list pgsql-hackers

From Vadim B. Mikheev
Subject bug: HashJoin and backward cursors...
Date
Msg-id 34E01ECC.EA5F1837@sable.krasnoyarsk.su
Whole thread Raw
List pgsql-hackers
tempx and tempx2 are tables with single int4 field. Having single record
with value of 1 in both tables:

vac=> explain select * from tempx, tempx2 where tx = tx2;
NOTICE:  QUERY PLAN:

Hash Join  (cost=17.20 size=100 width=8)
  ->  Seq Scan on tempx2  (cost=4.30 size=100 width=4)
  ->  Hash  (cost=0.00 size=0 width=0)
        ->  Seq Scan on tempx  (cost=4.30 size=100 width=4)

EXPLAIN
vac=> begin;
BEGIN
vac=> declare c cursor for select * from tempx, tempx2 where tx = tx2;
SELECT
vac=> fetch 1 in c;
tx|tx2
--+---
 0|  0
(1 row)

vac=> fetch 1 in c;
tx|tx2
--+---
 1|  1
(1 row)
vac=> fetch backward 1 in c;
tx|tx2
--+---
 0|  0
(1 row)
^^^^^^^^^^^^^^^^^^^^^^ - very nice!
vac=> end;
END
vac=> insert into tempx values (1);
INSERT 320416 1
vac=> begin;
BEGIN
vac=> declare c cursor for select * from tempx, tempx2 where tx = tx2;
SELECT
vac=> fetch 1 in c;
tx|tx2
--+---
 0|  0
(1 row)

vac=> fetch 1 in c;
tx|tx2
--+---
 1|  1
(1 row)

vac=> fetch backward 1 in c;
tx|tx2
--+---
 1|  1
(1 row)
^^^^^^^^^^^^^^^^^^^^^^^^^^

HashJoin doesn't care about scan dirrection...

This is another story:

vac=> fetch backward 1 in c;
tx|tx2
--+---
 0|  0
(1 row)

vac=> fetch backward 1 in c;
tx|tx2
--+---
(0 rows)

vac=> fetch 1 in c;
PQexec() -- Request was sent to backend, but backend closed the channel before responding.
        This probably means the backend terminated abnormally before or while processing the request.

Vadim

pgsql-hackers by date:

Previous
From: "Maurice Gittens"
Date:
Subject: Where to get snapshots
Next
From: "Meskes, Michael"
Date:
Subject: RE: [HACKERS] Bug?