From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Provide more-specific error details/hints for function lookup fa |
Date: | 2025-09-16 16:17:23 |
Message-ID: | E1uyYMs-0011lv-1T@gemulon.postgresql.org |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Provide more-specific error details/hints for function lookup failures.
Up to now we've contented ourselves with a one-size-fits-all error
hint when we fail to find any match to a function or procedure call.
That was mostly okay in the beginning, but it was never great, and
since the introduction of named arguments it's really not adequate.
We at least ought to distinguish "function name doesn't exist" from
"function name exists, but not with those argument names". And the
rules for named-argument matching are arcane enough that some more
detail seems warranted if we match the argument names but the call
still doesn't work.
This patch creates a framework for dealing with these problems:
FuncnameGetCandidates and related code will now pass back a bitmask of
flags showing how far the match succeeded. This allows a considerable
amount of granularity in the reports. The set-bits-in-a-bitmask
approach means that when there are multiple candidate functions, the
report will reflect the match(es) that got the furthest, which seems
correct. Also, we can avoid mentioning "maybe add casts" unless
failure to match argument types is actually the issue.
Extend the same return-a-bitmask approach to OpernameGetCandidates.
The issues around argument names don't apply to operator syntax,
but it still seems worth distinguishing between "there is no
operator of that name" and "we couldn't match the argument types".
While at it, adjust these messages and related ones to more strictly
separate "detail" from "hint", following our message style guidelines'
distinction between those.
Reported-by: Dominique Devienne <ddevienne(at)gmail(dot)com>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Robert Haas <robertmhaas(at)gmail(dot)com>
Discussion: https://postgr.es/m/1756041.1754616558@sss.pgh.pa.us
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/83a56419457ec0eff2eddfed8eb3aba86bede9cc
Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 6 +-
doc/src/sgml/sources.sgml | 7 +-
doc/src/sgml/typeconv.sgml | 10 +-
src/backend/catalog/namespace.c | 118 ++++++++++++----
src/backend/catalog/pg_aggregate.c | 2 +
src/backend/parser/parse_func.c | 148 ++++++++++++++++++---
src/backend/parser/parse_oper.c | 69 ++++++++--
src/backend/utils/adt/regproc.c | 19 ++-
src/backend/utils/adt/ruleutils.c | 2 +
src/include/catalog/namespace.h | 24 +++-
src/include/parser/parse_func.h | 1 +
src/pl/plperl/expected/plperl_elog.out | 2 +-
src/pl/plperl/expected/plperl_elog_1.out | 2 +-
src/pl/plpgsql/src/expected/plpgsql_call.out | 3 +-
src/pl/plpgsql/src/expected/plpgsql_record.out | 3 +-
src/pl/plpython/expected/plpython_error.out | 2 +-
.../libpq_pipeline/traces/pipeline_abort.trace | 2 +-
.../test_extensions/expected/test_extensions.out | 3 +-
src/test/regress/expected/alter_table.out | 3 +-
src/test/regress/expected/arrays.out | 3 +-
src/test/regress/expected/create_cast.out | 6 +-
src/test/regress/expected/create_function_sql.out | 3 +-
src/test/regress/expected/create_operator.out | 19 +++
src/test/regress/expected/create_procedure.out | 5 +-
src/test/regress/expected/create_view.out | 3 +-
src/test/regress/expected/domain.out | 3 +-
src/test/regress/expected/expressions.out | 3 +-
src/test/regress/expected/geometry.out | 3 +-
src/test/regress/expected/horology.out | 3 +-
src/test/regress/expected/misc_functions.out | 4 +-
src/test/regress/expected/multirangetypes.out | 15 ++-
src/test/regress/expected/plpgsql.out | 11 +-
src/test/regress/expected/polymorphism.out | 143 +++++++++++++++-----
src/test/regress/expected/rangetypes.out | 9 +-
src/test/regress/expected/rowtypes.out | 6 +-
src/test/regress/expected/subselect.out | 3 +-
src/test/regress/expected/temp.out | 2 +-
src/test/regress/expected/text.out | 6 +-
src/test/regress/expected/time.out | 3 +-
src/test/regress/expected/timetz.out | 3 +-
src/test/regress/expected/with.out | 3 +-
src/test/regress/expected/xid.out | 12 +-
src/test/regress/sql/create_operator.sql | 7 +
src/test/regress/sql/polymorphism.sql | 20 +++
44 files changed, 573 insertions(+), 151 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Noah Misch | 2025-09-16 16:42:28 | pgsql: Fix pg_dump COMMENT dependency for separate domain constraints. |
Previous Message | Bruce Momjian | 2025-09-16 15:49:14 | pgsql: doc PG 18 relnotes: add mention of temporal foreign key constr. |