From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix failure in function cache entry hashing during validation mo
Date: Sun, 01 Nov 2026 22:28:32 +0000
Message-ID: <E1xNe2S-00000001iGe-11qp@gemulon.postgresql.org> (raw)
Fix failure in function cache entry hashing during validation mode.
When cached_function_compile() is called with forValidator = true,
the passed FunctionCallInfo is one that the caller set up specially,
and it's typically pretty incomplete. compute_function_hashkey()
was careless about this and would call get_call_result_type()
if asked to, which would fail in any but the simplest cases.
We'd managed not to notice in the pre-existing use-cases because
plpgsql and functions.c don't pass includeResultType and forValidator
both true at the same time; but plpython does, so it would reach this
failure in cases such as polymorphic argument types. plpython does
not yet support polymorphic arguments, and has no test cases about
them, so we did not see that the intended error message had degraded
to an internal failure in get_call_result_type().
To fix, just skip trying to fill the result type tupdesc when in
validation mode. This leads to building a hashtable entry that will
never match any real calls, but that's true in a lot of other
validation cases as well.
The root cause here is lack of clarity about what we expect the
passed FunctionCallInfo to contain in validation mode, so add
comments specifying that. Also add some plpython test cases showing
the expected error reports.
Backpatch to v18 where funccache.c was introduced. This problem's
not reachable in the core code in v18, since plpython didn't use
funccache.c then. But extensions could perhaps be using funccache.c
as of v18, and they might hit it.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: shihao zhong <zhong950419@gmail.com>
Discussion: https://postgr.es/m/2865288.1793403201@sss.pgh.pa.us
Backpatch-through: 18
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/2316a7dcdd3b365242598b2d788e2a4458c5fb15
Modified Files
--------------
src/backend/utils/cache/funccache.c | 15 ++++++++++++---
src/pl/plpython/expected/plpython_error.out | 10 ++++++++++
src/pl/plpython/sql/plpython_error.sql | 10 ++++++++++
3 files changed, 32 insertions(+), 3 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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Fix failure in function cache entry hashing during validation mo
In-Reply-To: <E1xNe2S-00000001iGe-11qp@gemulon.postgresql.org>
References: <E1xNe2S-00000001iGe-11qp@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