Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w9gOY-001e8H-1x for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 09:37:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w9gOV-007X2y-2W for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 09:37:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w9gOV-007X2o-0t for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 09:37:19 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w9gOS-00000000pYh-3O9l for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 09:37:18 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5a2b542cbaaso4089554e87.0 for ; Mon, 06 Apr 2026 02:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775468233; cv=none; d=google.com; s=arc-20240605; b=GhYE19mmtyP5GLWQlwVcc3PY9kzfHy1dx6Vq6PNltrs/WO03tKCZaH7guqGO/e8iKs ScJMmRltQDL/ziqyEA0vPn5v/vXj77+1uzD8C1ip12iNByzI3syXK5XT2BWh+WIHWxL0 sHSf3pbLCWbBULA7K0z238/JBp1ZyH6cJVUwYmAJK8gBjaM+88qoysj+HfIFvU0ROKle hOzbaMjzmGNcHA0YbfeI05d8o0uZ0P6MxSyijq7dYcCrd74Ne7TwI/v6Z9AIaCs8PPEs vC9raFvqlf98b7/adNCefKeLFJBPUn1KVXhJRqmyYCVHF5pYDYpRDj/YJEnTliOO6vZK /O0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=xIKDibhCp2mg96sQRfqq7magMYv/DeJLKVxNSTJeGo4=; fh=nP6T31bp96BQH7n1StDf+JRmoaBSm83n0uTTdMOxa3Q=; b=k4Yk7iZXz2n/ZDAgZsuOs8TftO+kxvb4gHG18DxBJMaF+HA8tk0dJTqikwaOdLiPlu 82zVbg59D6JonfpZxx6GhDmU6kktMSWKsrZM2C+x/tkfIUhrR0uSP0l/3le0VD8UTgP1 l1SmSILr3Tg0xpdNMLeGVlw6Siv+32ditquqLB3D3AUGaadd26oyRLUjluDyrdGvDh4h vKS++GP0k2K5RV7P4uN1etlCPDO/iY4n+cWRbPs7mJEYfdtWbbNZS+8moj5L5kNFnbVk G5agilJGNj9BlW/cg43i2yXEpfMBVb5fU6JixBc7+3S3ai1IenTbtC5V2nAmQI/DKHXW Y7Mw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jeltef.nl; s=google; t=1775468233; x=1776073033; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=xIKDibhCp2mg96sQRfqq7magMYv/DeJLKVxNSTJeGo4=; b=e5NGZXGMvAi21RO4rqHI83CtwXEEdo/Fu21lkgeP9OV6BLqJhUU43eBVw23N0QoAJ2 Jd1sIVdhrU5O+9dS3dOJR3WyQ6MenVroigEGsE+xGE1JH9L/wiIk8b5khKqVzsNKN9lA b3mHOJQ0y8VNSxdOvf47DMO5xTLp/DO1Hk7jP2O/yQ1U/q8oQDKtcIXav2i+wvbqe/bF M9xWS+CPPOCIi8N9LP9Hn7jhNA1+YAeNgXxFoIHBQv39WcojoSwmJ8F9b8vG8tCiR8ub xBchHFQ8TsK3BMfb5sthsprf0OtA0DsYOnx3OR9s/G1DNQH80Rmnr1VoS+NALMXAimZT 5DGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775468233; x=1776073033; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xIKDibhCp2mg96sQRfqq7magMYv/DeJLKVxNSTJeGo4=; b=WgzzDDSXw5BK3SZMHjvqMU4d3wLEN/ieXOi+X6RtzxK7lluaotCqSyUdPYzLkd+k75 i4BVAlM3VE5MJbITBAN5W4TUehyfw/nR1yssKjD4QOJH7L4KJ8rjsMVBjucppueGobMi O1L4F11Q1zhEEM6ixNdqdv5t52olHYzFpz5acrZzzDNsJR5z3TB2BNE9Mx816jNMEHHc fMuoit7Opc5JED50q8OVWQlYVAqCfB4bqkQvbLivKJD/4RRtSibQN8Lg1PTqlPRjBPhk /5Nd8qzSccH8vVMmeAGcNAAmvDABmGROovlqnpTMLnqoYeupOFdsHkWH6u1yKdZdhy0q 1f2g== X-Forwarded-Encrypted: i=1; AJvYcCXEt6cV+lSgG9j8CriKQC3mty9dlIAU2HYh7S8dIqJTXwp6nGEI88chUVWZ4RTM4zriT3A43JsrVOeeCfab@lists.postgresql.org X-Gm-Message-State: AOJu0Yway0RekKv6Jp4RYMc292/9iodBvIHr4CodXZunukzJ4HpUbRL0 rjMuK8rRT8Z3XkeMbQz9hjoAYq5EXuhoGBzxmrYXxwTElAivl4apX0cn04D2o4Sqw6DCntLlnSM ldjjk6BzMYHMVBMMye3El6NGBzUlHUfrOtMS5U4GlfQ== X-Gm-Gg: AeBDievB6wwX0eWN6sPK9wX2oUQR8YH4PrMgxNGJMPluTRMlqGTVj7vTZRqXh4qJ6UV 046HOFFcrht0IJ6h+vI2qaKUsiLs3Gj4uSkWBOm9izonrY5o9Y1KU6tuiaHhM05ZnuvFhVuH0Zz RNuKWb2c/EGbkTu7+qThmtWTbgEI1ZM2fJk8dRIp6q18up4NTosO8f6gFx8Ucdim8sQrDDKBA76 LHxONfuRfzJcGsstz9VO8ccUZR7If0KF0rMe0AbWpD4IQpr0afSVL03c+1COzXhlffKfi3sH08a JKCyTICbHVi94ycW8yYI1LIDaTTRyk0kBru0 X-Received: by 2002:a05:6512:6d2:b0:5a2:aec9:95f8 with SMTP id 2adb3069b0e04-5a33756030cmr3985010e87.17.1775468232422; Mon, 06 Apr 2026 02:37:12 -0700 (PDT) MIME-Version: 1.0 References: <2155281.1767900170@sss.pgh.pa.us> <431484.1768433414@sss.pgh.pa.us> In-Reply-To: From: Jelte Fennema-Nio Date: Mon, 6 Apr 2026 11:37:01 +0200 X-Gm-Features: AQROBzCcHSrK5rIMLxin1hj1iYOfTjBBo8V0xprZVkU6UsBbS65KPZb-Vm5r01U Message-ID: Subject: Re: Proposal to allow setting cursor options on Portals To: Dave Cramer Cc: Sami Imseih , Hannu Krosing , Robert Haas , Tom Lane , Jacob Champion , PostgreSQL Hackers , Heikki Linnakangas Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 25 Mar 2026 at 15:34, Dave Cramer wrote: > Attached is v4 of the patch > Co-Authored by Sami Imseih > > Adds docs and test module It's looking much more finished > The portal can > later be operated on with cursor commands such as FETCH, MOVE, > and CLOSE. This made me realize that, adding the Bind side of cursors is only half of the equation. The "Execute" message should also gain new behaviour to support all the same functionality as FETCH and MOVE. I think we can do that fairly easily by adding similar flags to Execute. I think we'd need three flags: 1. MOVE 2. BACKWARD 3. ABSOLUTE I do realize the scope creep of this, but it feels that without addressing Execute we have a half-finished feature. That could be fine, but then I don't think we should call the option _pq_.protocol_cursor. Because that sounds like it solves the whole half-baked protocol-level cursor implemention that we currently have. Maybe _pq_.cursor_bind instead. I think the "protocol_" part in _pq_.protocol_cursor is duplicative. The _pq_ part already indicates that it's a protocol option, so I'd leave that out. > PQ_BIND_CURSOR_SCROLL (scroll), > PQ_BIND_CURSOR_NO_SCROLL (no scroll), and > PQ_BIND_CURSOR_HOLD (hold). > These are defined in libpq-fe.h. and > > Bitmap set by protocol extensions. > I think the Message Formats page should list the actual flag values that are valid. The protocol docs should not require you to look at the postgres source code. /* * Only override the default cursorOptions when the client has * explicitly set flags. A value of 0 means no cursor options were * requested, so keep the CreatePortal defaults. */ What is the difference between setting cursorOptions = 0 and the CreatePortal defaults? > {"protocol_cursor", NULL, "0", NULL, > "Protocol-Cursor", "", 1, > offsetof(struct pg_conn, protocol_cursor)}, In my GoAway patchset I linked enabling the protocol extension to the user requesting protocol v3.2 (or higher). > /* Reject any bits we don't recognize */ > if (bind_ext_flags & ~0x0007) Let's use PQ_BIND_CURSOR_VALID_FLAGS here too instead of this magic number. > src/test/modules/libpq_protocol_cursor/libpq_protocol_cursor.c I think it'd be better to put these tests in the libpq_pipeline test file. Then we can keep all the libpq tests together so they can share the helper logic.