Re: BUG #15336: Wrong cursor's bacward fetch results in select with ALL(subquery)
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: pgsql-bugs@lists.postgresql.org, v.g.baranoff@gmail.com
Date: 2018-08-17T14:04:11Z
Lists: pgsql-bugs
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
Commits
-
Set scan direction appropriately for SubPlans (bug #15336)
- 807c1c555064 9.3.25 landed
- 3cf3a65cb7da 9.4.20 landed
- d2ecc27c374a 9.5.15 landed
- 6302fe6b28e2 9.6.11 landed
- d31ebbff5b2b 10.6 landed
- 67b161eae32b 11.0 landed
- 520acab17124 12.0 landed
-
Get rid of the separate EState for subplans, and just let them share the
- c7ff7663e47f 8.3.0 cited