From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Retire PQfn().
Date: Fri, 14 Aug 2026 16:30:43 +0000
Message-ID: <E1wuunq-00000000ZIw-1aCF@gemulon.postgresql.org> (raw)
Retire PQfn().
PQfn() has been documented as somewhat obsolete since commit
efc3a25bb0 (2003), and commit bd48114937 recently marked it unsafe
because it may write past the end of result_buf when result_is_int
is 0. Furthermore, searches of publicly available code turned up
no callers, only language bindings that expose the function
without using it, so removing it seems unlikely to cause too much
trouble.
Since the symbol is exported, deleting it outright isn't an option,
so instead this commit teaches PQfn() to fail unconditionally with
an error that suggests alternatives. The documentation for the
fast-path interface is replaced with a stub in the "Obsolete or
Renamed Features" appendix. The server's fast-path support is
retained for the benefit of older clients and the frontend large
object interface.
The frontend large object interface, the only in-tree caller, now
uses PQnfn(), the private version of PQfn() added by commit
bd48114937. I considered converting this code away from the
fast-path protocol entirely, but prepared statements can be
deallocated out from under libpq (e.g., by DISCARD ALL), and
PQexecParams() proved noticeably slower, so that is left as a
future exercise.
Reviewed-by: Christoph Berg <myon@debian.org>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Discussion: https://postgr.es/m/ahXE28klgxIJXBLq%40nathan
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/40af05bb6157670482ae31fd5b0a12ff2992c966
Modified Files
--------------
doc/src/sgml/appendix-obsolete-libpq-fastpath.sgml | 30 ++++++
doc/src/sgml/appendix-obsolete.sgml | 1 +
doc/src/sgml/filelist.sgml | 1 +
doc/src/sgml/libpq.sgml | 117 +--------------------
src/backend/tcop/fastpath.c | 4 +-
src/include/tcop/dest.h | 4 +-
src/interfaces/libpq/fe-exec.c | 55 ++++++++--
src/interfaces/libpq/fe-lobj.c | 38 +++----
src/interfaces/libpq/fe-protocol3.c | 6 +-
src/interfaces/libpq/libpq-fe.h | 3 +-
10 files changed, 107 insertions(+), 152 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Retire PQfn().
In-Reply-To: <E1wuunq-00000000ZIw-1aCF@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox