On Fri, 16 Jun 2023 at 16:26, Craig Ringer <cr...@2ndquadrant.com> wrote: > Nobody's implemented it. > > A patch to add PQclosePrepared and PQsendClosePrepared would be welcome. At > least, I think so...
This might have been a pretty old thread. But I just took it upon me to implement these functions (or well I mostly copied the PQsendDescribe related code and did s/describe/close). I haven't tested this code yet but I'm pretty sure it should just work (it compiles at least). The main reason I'm interested in this is because we're actively working on implementing named prepared statement support for PgBouncer in transaction pooling mode. It works with lots of client libraries already. But sadly it doesn't work with psycopg at the moment, or at least the closing part does not. And the reason is that psycopg closes statements using a DEALLOCATE query instead of the Close protocol message, because libpq does not support sending the Close protocol message. Afaict this is not just a problem for PgBouncer its implementation. As far as I can tell the same is true for the Odyssey connection pooler (which implemented named prepared statement support first).
v1-0001-Support-sending-Close-messages-from-libpq.patch
Description: Binary data