pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: pgsql-bugs@lists.postgresql.org
Cc: v.g.baranoff@gmail.com
Subject: Re: BUG #15336: Wrong cursor's bacward fetch results in select with ALL(subquery)
Date: Fri, 17 Aug 2018 11:04:11 -0300
Message-ID: <20180817140411.crhfn3machmctt7n@alvherre.pgsql> (raw)
In-Reply-To: <87va892tf5.fsf@news-spur.riddles.org.uk>

On 2018-Aug-17, Andrew Gierth wrote:

> I wonder if we have a contender here for the oldest reported bug in PG
> history; while I haven't tested anything older than 9.5, the incorrect
> logic seems to date back to the introduction of subqueries in
> 6.something.

Hmm ..

> begin;
> declare foo cursor for select * from generate_series(1,3) i where i <> all (values (2));
> fetch all from foo;  -- returns the expected 2 rows
> fetch backward all from foo;  -- assertion failure, or incorrect result

8.2 seems fine:

alvherre=# show debug_assertions;
 debug_assertions 
------------------
 on
(1 fila)

alvherre=# begin;
BEGIN
alvherre=# declare foo cursor for select * from generate_series(1,3) i where i <> all (values (2));
DECLARE CURSOR
alvherre=# fetch all from foo;
 i 
---
 1
 3
(2 filas)
alvherre=# fetch backward all from foo;
 i 
---
 3
 1
(2 filas)

9.1 does fail an assertion:

TRAP: FailedAssertion(«!(forward || (readptr->eflags & 0x0004))», Archivo: «/pgsql/source/REL9_1_STABLE/src/backend/utils/sort/tuplestore.c», Línea: 765)

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (8+ messages)  latest in thread

Message-ID: <20180817140411.crhfn3machmctt7n@alvherre.pgsql>
Permalink:  ../20180817140411.crhfn3machmctt7n@alvherre.pgsql/
Also on:    postgresql.org/message-id/20180817140411.crhfn3machmctt7n@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@2ndquadrant.com, andrew@tao11.riddles.org.uk, pgsql-bugs@lists.postgresql.org, v.g.baranoff@gmail.com
  Subject: Re: BUG #15336: Wrong cursor's bacward fetch results in select with ALL(subquery)
  In-Reply-To: <20180817140411.crhfn3machmctt7n@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox