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 1wUXL7-001EXF-1c for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jun 2026 22:12:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wUXL6-00G79U-1T for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jun 2026 22:12:00 +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 1wUXL5-00G79J-36 for pgsql-hackers@lists.postgresql.org; Tue, 02 Jun 2026 22:12:00 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wUXL3-00000000wDD-2d7l for pgsql-hackers@postgresql.org; Tue, 02 Jun 2026 22:11:59 +0000 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-48611ccd5aeso2043869b6e.2 for ; Tue, 02 Jun 2026 15:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780438315; x=1781043115; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Q5RSjIomTL+KIGHaFoZBNObXQO0HUVfKgCz8fx7IfCc=; b=lQa3swvhrUcT8fn1K5pG03xdrVFxa8bTvRYaabJTYeTSSCwnjzFDl5DA/j4tI78Giv tXdBp+PQ3Dyn+o1d9reAW85/vtxScBUL6Bll4KR7n24ui1d9ilLzgqaOMSPJw9pbPrYX WfMKglTN++2fctiWZKubhmnfKlZJnExyCVC40jDd3bxI7PJKxTf4KhQGNDJw8xulczHu Q4mEkRrjQp36WTA7J0Yo52wKBT2X5vCYazsHZZhFb8EY9ftktOFT2jANN2WIManVRC39 qjdjC7Vo/0IK2ZquW+qcDpxLAlAIL0TcGg8b6EWLiLg4g3z5Pywxa99G19RV8rtirUGA q2/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780438315; x=1781043115; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q5RSjIomTL+KIGHaFoZBNObXQO0HUVfKgCz8fx7IfCc=; b=LiHr5hWHV4zVRS85Lr/AJWuw70+kBnYJNyFSDSe4fLNG5YEyQCtIY2J59HszAfHEZx u7A5wywk8kp7RfRncc3KdiTgCTc90GR2RWzIiTPnw0CEd4OvG4iu6cIRrbGbroiJz6lh QpkNIU62asx9iQ0X0VFduHhCf+APhJgBWBqxKhQKoyI/z1AoEjrWv6HKnzQ2a0jNx7E+ PsDQ/2sMtvDAlffAuWNAekzGnxvEUzMBA2qsy2yJGvXwfHYe3KQGUUX8pN+tU/ymF/hA F2pJucsaFjhQzCIoL8AQJWJB3mLUx9BQ0GPs4+pvg2Ww79JGKQXX9uZVzj5M7tZ1dA9m mXuQ== X-Forwarded-Encrypted: i=1; AFNElJ/WmOTBHr1FsU1UY9H4d4fR5w/5q1j2/zyQPAVOsZER1rbUnFJfYuMooMTfnuIkrZNkB38kTjvR8d0vODan@postgresql.org X-Gm-Message-State: AOJu0Yya4Akced7mcSutZcLe5ZSTt1S4O4oEatNczwWtyU/w4zCrG7zP hY/pjaoJr7gXiMs+iTJclsDxQ79DedTT0rSrlasTBl4/q+cDajVtWlvdpTAzEQ== X-Gm-Gg: Acq92OHkQrSZ2a3cHTI6V0a0su8tmlIF1ZWW/tsDBDkC6RXUhYkeOhYc8UIkY0Hriat Af+ee7Ib+faBX0VAK5aagZFiVl7raSQLHPcaDSfd/BGzZdR11aZP+uTzEjQTqu0NtXz04fkm6ok O0Z4qXoMMqqQwaanrc4UKF9pvdY193/iAseQhBQrM16AhiVWNcah1sCyKnh/162YucRI8Le8geB SNMnIX3/4cO1RusKRfbZOAdOowsUUYtFD5YuVu2GLEY7nAMqpEMPP5ZTqt6FC3vXyNiIEskKeg3 nqb7nqFRIDdCe7eeVUlwpVeecri7XM8qU+yPidXkskBcgzwqK5Y9vAY5wr4zi5TnCNHrDL8RWqs Ji4nCs/Xj4B/3TvKZAfpy2Hcr1bUgjJoauNlA9gtv6a6na3DREtQbw7UDghzOJO1b3VBxAGLQPM npyoeVARefGAszh86S6FXuomx75zMEB72r3EiFNUiUi93DBHGsN9y2U+nUZ+NKY2no75Un94jkB PQzrZBcP66N2uXlFoJ51mV7pK169YE0 X-Received: by 2002:a05:6808:f8e:b0:45e:84e7:c20b with SMTP id 5614622812f47-4865aae1d15mr496420b6e.25.1780438315280; Tue, 02 Jun 2026 15:11:55 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-440d7d4f449sm856575fac.8.2026.06.02.15.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:11:54 -0700 (PDT) Date: Tue, 2 Jun 2026 17:11:52 -0500 From: Nathan Bossart To: Tom Lane Cc: Jacob Champion , pgsql-hackers@postgresql.org Subject: Re: alert clients when prepared statements are deallocated Message-ID: References: <1689313.1780074543@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="569rkL4UxgNPPO44" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --569rkL4UxgNPPO44 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I've spent quite a bit of time on this one. Attached is a new version of the patch. A few notes: * This version uses a protocol extension instead of bumping the protocol version. It looks like this is the first such extension, so it's entirely possible I'm missing something. Note that this should work for any version of PostgreSQL released since 2018 (see commit ae65f6066d), but IIUC older versions will error on the protocol extension. I'm a little concerned that this could break pg_upgrade from early versions of v10 (which will be the minimum supported source version in v20), so we might need to provide a way to disable it in libpq. * I sketched out an alternative design that would allow client applications to retrieve the notifications at their leisure, but I stopped when I realized this would actually add quite a bit of complexity. We have to think about duplicate reports, specifying which statements to collect, clearing reports, and other subtle behavior. I'm hopeful that the callback mechanism is good enough for now. If feedback indicates it is not, we can certainly re-evaluate as a follow-up effort. * I didn't add notifications for unnamed prepared statements. I'm not seeing a real use-case for that, but I admittedly haven't thought about it too hard. * I haven't added any tests in this patch. My thinking is that it will get tested as part of the libpq-LO-interface revamp in the other thread. * I'm a little worried about race conditions involving a client trying to use a statement while a deallocation message is in flight, but I haven't identified anything concrete so far. This is something I'd like to investigate some more, though. -- nathan --569rkL4UxgNPPO44 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0001-tell-client-when-prepared-statements-are-dealloca.patch