summaryrefslogtreecommitdiff
path: root/src/pl
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2025-09-16 12:17:02 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2025-09-16 12:17:02 -0400
commit83a56419457ec0eff2eddfed8eb3aba86bede9cc (patch)
treec93d0986e7d19c763c2d0965d98edc8d336b78ea /src/pl
parentc7b0cb367d3c6b007122457ad5deb659fe8cc266 (diff)
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@gmail.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Discussion: https://postgr.es/m/1756041.1754616558@sss.pgh.pa.us
Diffstat (limited to 'src/pl')
-rw-r--r--src/pl/plperl/expected/plperl_elog.out2
-rw-r--r--src/pl/plperl/expected/plperl_elog_1.out2
-rw-r--r--src/pl/plpgsql/src/expected/plpgsql_call.out3
-rw-r--r--src/pl/plpgsql/src/expected/plpgsql_record.out3
-rw-r--r--src/pl/plpython/expected/plpython_error.out2
5 files changed, 7 insertions, 5 deletions
diff --git a/src/pl/plperl/expected/plperl_elog.out b/src/pl/plperl/expected/plperl_elog.out
index a6d35cb79c4..6343962b81d 100644
--- a/src/pl/plperl/expected/plperl_elog.out
+++ b/src/pl/plperl/expected/plperl_elog.out
@@ -41,7 +41,7 @@ select uses_global();
ERROR: function uses_global() does not exist
LINE 1: select uses_global();
^
-HINT: No function matches the given name and argument types. You might need to add explicit type casts.
+DETAIL: There is no function of that name.
SET plperl.use_strict = false;
create or replace function uses_global() returns text language plperl as $$
diff --git a/src/pl/plperl/expected/plperl_elog_1.out b/src/pl/plperl/expected/plperl_elog_1.out
index 85aa460ec4c..a85dd17b579 100644
--- a/src/pl/plperl/expected/plperl_elog_1.out
+++ b/src/pl/plperl/expected/plperl_elog_1.out
@@ -41,7 +41,7 @@ select uses_global();
ERROR: function uses_global() does not exist
LINE 1: select uses_global();
^
-HINT: No function matches the given name and argument types. You might need to add explicit type casts.
+DETAIL: There is no function of that name.
SET plperl.use_strict = false;
create or replace function uses_global() returns text language plperl as $$
diff --git a/src/pl/plpgsql/src/expected/plpgsql_call.out b/src/pl/plpgsql/src/expected/plpgsql_call.out
index ea7107dca0d..3d0b117f236 100644
--- a/src/pl/plpgsql/src/expected/plpgsql_call.out
+++ b/src/pl/plpgsql/src/expected/plpgsql_call.out
@@ -440,7 +440,8 @@ $$;
ERROR: procedure test_proc12(integer, integer, text[]) does not exist
LINE 1: CALL test_proc12(_a, _b, _c)
^
-HINT: No procedure matches the given name and argument types. You might need to add explicit type casts.
+DETAIL: No procedure of that name accepts the given argument types.
+HINT: You might need to add explicit type casts.
QUERY: CALL test_proc12(_a, _b, _c)
CONTEXT: PL/pgSQL function inline_code_block line 5 at CALL
-- transition variable assignment
diff --git a/src/pl/plpgsql/src/expected/plpgsql_record.out b/src/pl/plpgsql/src/expected/plpgsql_record.out
index e5de7143606..511f9e03c85 100644
--- a/src/pl/plpgsql/src/expected/plpgsql_record.out
+++ b/src/pl/plpgsql/src/expected/plpgsql_record.out
@@ -466,7 +466,8 @@ select getf1(1);
ERROR: function getf1(integer) does not exist
LINE 1: select getf1(1);
^
-HINT: No function matches the given name and argument types. You might need to add explicit type casts.
+DETAIL: No function of that name accepts the given argument types.
+HINT: You might need to add explicit type casts.
select getf1(row(1,2));
getf1
-------
diff --git a/src/pl/plpython/expected/plpython_error.out b/src/pl/plpython/expected/plpython_error.out
index fd9cd73be74..96bbdfb9586 100644
--- a/src/pl/plpython/expected/plpython_error.out
+++ b/src/pl/plpython/expected/plpython_error.out
@@ -63,7 +63,7 @@ SELECT exception_index_invalid_nested();
ERROR: spiexceptions.UndefinedFunction: function test5(unknown) does not exist
LINE 1: SELECT test5('foo')
^
-HINT: No function matches the given name and argument types. You might need to add explicit type casts.
+DETAIL: There is no function of that name.
QUERY: SELECT test5('foo')
CONTEXT: Traceback (most recent call last):
PL/Python function "exception_index_invalid_nested", line 1, in <module>