Adding an extra byte to ReadyForQuery (B) to indicate HOLD cursors

From: Hannu Krosing <hannuk(at)google(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Dave Cramer <davecramer(at)postgres(dot)rocks>
Subject: Adding an extra byte to ReadyForQuery (B) to indicate HOLD cursors
Date: 2025-11-28 11:47:53
Message-ID: CAMT0RQSpqcvjHy3tam+nuKhoDH7XWBVy2mOp8J=f0dH30Rukew@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi PostgreSQL Hackers

I started to look around for a solution of current pgJDBC shortcoming
of having to emulate WITH HOLD cursors and found this discussion
(https://github.com/pgjdbc/pgjdbc/discussions/3323) mentioning
connection pooling.

I did not find anything in the wire protocol documentation about
indicating the presence of cursos held over transactions, but this
info seems essential to properly handling them in case of transaction
pooling.

Would it make sense to add one more byte ('H' ?) at the end of the
ReadyForQuery backend message to indicate that there are cursors that
live across transactions, so thet the connection pooler knows to not
give the database connections to other clients while this is happening
?

Or should we keep the current structure of just one byte and add
another value to indicate "idle but with a cursor on hold" as the
cursor only matters if outside a transaction.

So the full set of values for Current backend transaction status
indicator becomes:
- 'I' if idle (not in a transaction block);
- 'T' if in a transaction block;
- 'E' if in a failed transaction block (queries will be rejected
until block is ended)
+ 'H' if idle but with a held cursor.

The second option, maybe together with a flag activating/disabling the
'H' option seems to be the least disruptive

Thoughts?

---
Hannu

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2025-11-28 11:53:25 Re: [PATCH] Add `headerscheck` run_target to meson
Previous Message Ajit Awekar 2025-11-28 11:39:04 Periodic authorization expiration checks using GoAway message