Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fqfMS-0006dA-Hs for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Aug 2018 14:04:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fqfMQ-0008MU-TL for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Aug 2018 14:04:18 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fqfMQ-0008MN-FF for pgsql-bugs@lists.postgresql.org; Fri, 17 Aug 2018 14:04:18 +0000 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fqfMN-0006zk-4v for pgsql-bugs@lists.postgresql.org; Fri, 17 Aug 2018 14:04:17 +0000 Received: by mail-qt0-x242.google.com with SMTP id e19-v6so8815894qtp.8 for ; Fri, 17 Aug 2018 07:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=S4iAOu54JHt6rspNQtZTJ7bnMDFNCf5zXyIrVMNNOGo=; b=gTQd4rDGdmYtW0BQJwfysYaXooma+eRyY8Phl53wUJU6ELuq7gvBlsu1xrHrV9oDjT 7HE9tyeUb4OD6hQvTEifNSlsUJGYsQ/PDd2i96y749hUrxyCdkoqQI0MuGoa1FeLkDQV 1JRmrECskaAwuGIC7nS0dRSV95oNu6Iatw+/h28ZXJWPi6HyiX/3wsAFrq+EZNtEOYvT 9JC7kOHACzw52e+bu5jIDO5A333BKTWlPd7R5Ypo9eswqCUqDtLKu1An1zb/BFBesipp ZmYd47gHt6BpWj3SzJkIlplI36oTwm1AmMSHhFR31kVhEvQtS9CiQX6pcdDvF/RhPnBq /NvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=S4iAOu54JHt6rspNQtZTJ7bnMDFNCf5zXyIrVMNNOGo=; b=gt7q9jg5E22YqV6NPW68JOufiLuVopB5FEezSWXbGQ6yHiCmaAQurXr8GD7QitVR0k bbTxgQd9yD8A7nzR+P8Y8oylMg4GWNslC2C/xmAxvRsdm25CDt2455e1Z3tHYW+9BuK9 47VysxNYz+dK+/dTtTq+4a/g3IQOY4kuWY5cSdugtAVESWFJQgVPGD1VR4yajQouhHv0 eRedC2X9yTFWnQRB6YwNEmdWmh2hBdDyMIWq4zn9s82jrCugyASRFTi1avNFLrVHfx2z WmuigXUO1wEaI7at6EnKl08FSFDKf2IkfmTwNOyA4gYM+B/KYuwso2YY7p++P3Yn0Yqu LwQQ== X-Gm-Message-State: AOUpUlEuQs9hHQoW16N2Te5wQAfMH4btpEQAiPLONyUSYWDR4ZKzFNUC f0cZMHi3jXNDz2z1IDFH/qMEEQ== X-Google-Smtp-Source: AA+uWPzoKrDldTosEPsp2GZ1nGTYNZPyVGF4qaLY/z2CwgAgk6mEEnKSy8qLa5kkbzWj6+DAyEthJg== X-Received: by 2002:aed:22ed:: with SMTP id q42-v6mr34009108qtc.193.1534514654104; Fri, 17 Aug 2018 07:04:14 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id 60-v6sm1197468qte.29.2018.08.17.07.04.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Aug 2018 07:04:13 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 553895BE; Fri, 17 Aug 2018 11:04:11 -0300 (-03) Date: Fri, 17 Aug 2018 11:04:11 -0300 From: Alvaro Herrera To: Andrew Gierth Cc: 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) Message-ID: <20180817140411.crhfn3machmctt7n@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87va892tf5.fsf@news-spur.riddles.org.uk> User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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