pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix failure in function cache entry hashing during validation mo 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix failure in function cache entry hashing during validation mo @ 2026-11-01 22:28 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2026-11-01 22:28 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ master Details ------- https://git.postgresql.org/pg/commitdiff/811527d9d46eabd4a577b16df486ca86b76a073e 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(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix failure in function cache entry hashing during validation mo @ 2026-11-01 22:28 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2026-11-01 22:28 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix failure in function cache entry hashing during validation mo @ 2026-11-01 22:28 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2026-11-01 22:28 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a4bc92a82c4e362e5b1dad83f86e5e1d93a970c5 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(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-11-01 22:28 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-01 22:28 pgsql: Fix failure in function cache entry hashing during validation mo Tom Lane <tgl@sss.pgh.pa.us> 2026-11-01 22:28 pgsql: Fix failure in function cache entry hashing during validation mo Tom Lane <tgl@sss.pgh.pa.us> 2026-11-01 22:28 pgsql: Fix failure in function cache entry hashing during validation mo Tom Lane <tgl@sss.pgh.pa.us>
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