Re: Proposal to allow setting cursor options on Portals

From: Dave Cramer <davecramer(at)gmail(dot)com>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Cc: Sami Imseih <samimseih(at)gmail(dot)com>, Hannu Krosing <hannuk(at)google(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: Proposal to allow setting cursor options on Portals
Date: 2026-03-25 14:34:42
Message-ID: CADK3HH+AKcTUas-W7ZodeVzfwJgXWQH8NM1O=-550eU-hgrB5A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 25 Mar 2026 at 03:46, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl> wrote:

> On Tue, 24 Mar 2026 at 11:01, Dave Cramer <davecramer(at)gmail(dot)com> wrote:
> > _pq_.cursor would be fine.
>
> I think that makes sense as a name for the option. I think adding flag
> support for SCROLL and NO SCROLL would make sense in that case.
>
> Some notes on the patch (but I didn't look look at the client side
> libpq code in detail):
>
> For the protocol definition I'd like a few changes:
> 1. I'd like the new field in the bind message that you add to be
> described as an extension bitmap, not specifically for cursor options,
> so that future extensions could add bits too it too.
> 2. Related to that, I think the used bits should not align with the
> internal bits. Having the only valid flag bit be 0x0020 is kinda
> weird. Let's just make that 0x0001. We could update the internal ones
> to match if desired, but I think it's fine for the protocol bits to
> differ from the bits in the postgres server.
>
> Docs still mention CURSOR_OPT_BINARY, but support for that has been
> removed from the code afaict (which I think is indeed what should
> happen)
>
> There's a bunch of protocol version 3.3 code still around, which
> should be removed now that the protocol option is added.
>
> PQsendBindWithCursorOptions and PQsendQueryPreparedWithCursorOptions
> should error out if conn->holdable_portal_enabled is false. Right now
> it silently skips the cursor options if the connection does not
> support the protocol extension.
>
> There should be a libpq function to inspect whether the connection
> supports cursor options, so some kind of graceful fallback logic can
> be implemented by the application when it's not supported.
>
> libpq docs are missing
>

Attached is v4 of the patch
Co-Authored by Sami Imseih

Adds docs and test module

Dave

Attachment Content-Type Size
v4-0001-Add-_pq_.cursor-protocol-extension-for-cursor-opt.patch application/x-patch 50.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2026-03-25 14:38:01 Re: Test timings are increasing too fast for cfbot
Previous Message Andrew Jackson 2026-03-25 14:24:18 Re: [PATCH] libpq: try all addresses for a host before moving to next on target_session_attrs mismatch