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 1wT0hs-000FuV-2B for pgsql-hackers@arkaria.postgresql.org; Fri, 29 May 2026 17:09:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wT0hq-003jzz-2s for pgsql-hackers@arkaria.postgresql.org; Fri, 29 May 2026 17:09:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wT0hq-003jzq-1z for pgsql-hackers@lists.postgresql.org; Fri, 29 May 2026 17:09:10 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wT0ho-00000000Axz-3usC for pgsql-hackers@postgresql.org; Fri, 29 May 2026 17:09:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 64TH93VL1689314; Fri, 29 May 2026 13:09:03 -0400 From: Tom Lane To: Nathan Bossart cc: Jacob Champion , pgsql-hackers@postgresql.org Subject: Re: alert clients when prepared statements are deallocated In-reply-to: References: Comments: In-reply-to Nathan Bossart message dated "Fri, 29 May 2026 11:33:37 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1689312.1780074543.1@sss.pgh.pa.us> Date: Fri, 29 May 2026 13:09:03 -0400 Message-ID: <1689313.1780074543@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > When trying to take our own advice and teach the frontend LO interface to > use prepared statements instead of PQfn(), I discovered a couple of > problems. The biggest problem is that clients aren't alerted when a > prepared statement is deallocated with DISCARD or DEALLOCATE. Of course the first question about that is "why doesn't the client know that already ... didn't it issue the deallocate itself?". The core answer to that question is that there might be multiple levels of client code involved, so that while some level of the client stack probably knows it in some way, other levels might have created prepared statements and not be aware that they're gone. Therefore, having the server report this is only a partial answer to the problem: it will only directly provide a fix to the bottom client code level. To go further you'd need some inside-the-client mechanism for propagating the notification up the client stack. We can't really create that in general, but we can at least make libpq be a responsible citizen in that chain. In short, a proposed fix for this must also provide a way for the calling application to hear about these reports, and a way for it to fall back if they're not available. regards, tom lane