Re: alert clients when prepared statements are deallocated

From: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
To: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: alert clients when prepared statements are deallocated
Date: 2026-06-05 09:34:14
Message-ID: CAGECzQQCKSogfz=Dqkf-+1GA13yATMu34CMU9Yqo13KXgmkW8Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 29 May 2026 at 19:07, Jacob Champion
<jacob(dot)champion(at)enterprisedb(dot)com> wrote:
> - let drivers pin protocol-level prepared statements so that
> application-level DISCARD doesn't touch them
> - explicitly separate client and middleware contexts or streams from each other
> - rebuild discarded prepared statements opportunistically on a failure

I think I like option 2 best (and after that 1). I'm often annoyed
that our application layer and protocol layer is so intertwined, so
any attempt to separate them is a welcome addition in my opinion.

One approach would be to:
1. add an optional additional text field to the Parse message as a
kind of "namespace" for prepared statements. Leaving this field out or
set to the empty string, would create an "application-level" prepared
statement. Setting it to anything else would create a protocol-level
prepared statement within that namespace. This would allow libpq to
create its own prepared statements, without conflicting with
protocol-level statements created by client libraries like psycopopg.
2. Application-level DISCARD/DEALLOCATE would not clean up these
namespaced protocol level prepared statements
3. Add a protocol-level version of DEALLOCATE ALL and DISCARD ALL
which also clean up all the protocol-level prepared statements
4. Add a protocol-level message to deallocate all prepared statements
in a certain schema.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-06-05 09:36:13 Re: Proposal: Conflict log history table for Logical Replication
Previous Message wenhui qiu 2026-06-05 09:32:47 Re: Reduce LEFT/FULL JOIN to ANTI JOIN in more cases