Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mONZX-00076Z-So for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Sep 2021 17:10:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mONZV-00019o-8M for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Sep 2021 17:10:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mONZV-00019f-0n for pgsql-hackers@lists.postgresql.org; Thu, 09 Sep 2021 17:10:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mONZN-0003vS-Kl for pgsql-hackers@lists.postgresql.org; Thu, 09 Sep 2021 17:10:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 189HAZQt3712912 for ; Thu, 9 Sep 2021 13:10:35 -0400 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: We don't enforce NO SCROLL cursor restrictions MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3712910.1631207435.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 09 Sep 2021 13:10:35 -0400 Message-ID: <3712911.1631207435@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk We don't actually prevent you from scrolling a NO SCROLL cursor: regression=3D# begin; BEGIN regression=3D*# declare c no scroll cursor for select * from int8_tbl; DECLARE CURSOR regression=3D*# fetch all from c; q1 | q2 = ------------------+------------------- 123 | 456 123 | 4567890123456789 4567890123456789 | 123 4567890123456789 | 4567890123456789 4567890123456789 | -4567890123456789 (5 rows) regression=3D*# fetch absolute 2 from c; q1 | q2 = -----+------------------ 123 | 4567890123456789 (1 row) There are probably specific cases where you do get an error, but we don't have a blanket you-can't-do-that check. Should we? The reason this came to mind is that while poking at [1] I noticed that commit ba2c6d6ce has created some user-visible anomalies for non-scrollable cursors WITH HOLD. If you advance the cursor a bit, commit, and then try to scroll the cursor, it will work but the part of the output that you advanced over will be missing. I think we should probably throw an error to prevent that from being visible. I'm worried though that putting in a generic prohibition may break applications that used to get away with this kind of thing. regards, tom lane [1] https://www.postgresql.org/message-id/CAPV2KRjd%3DErgVGbvO2Ty20tKTEZZr= 6cYsYLxgN_W3eAo9pf5sw%40mail.gmail.com