Add separate error message for procedure does not exist
authorPeter Eisentraut <peter_e@gmx.net>
Sat, 7 Jul 2018 09:17:04 +0000 (11:17 +0200)
committerPeter Eisentraut <peter_e@gmx.net>
Sat, 7 Jul 2018 09:17:04 +0000 (11:17 +0200)
While we probably don't want to split up all error messages into
function and procedure variants, this one is a very prominent one, so
it's helpful to be more specific here.

src/backend/parser/parse_func.c
src/test/regress/expected/create_procedure.out

index abe1dbc521cdaae0917c3cecb8042039343b7e31..c2feaf371fe674ddcbd74fd3ed29cd9818e09631 100644 (file)
@@ -542,14 +542,24 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
        if (is_column)
            return NULL;
 
-       ereport(ERROR,
-               (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
-                errmsg("function %s is not unique",
-                       func_signature_string(funcname, nargs, argnames,
-                                             actual_arg_types)),
-                errhint("Could not choose a best candidate function. "
-                        "You might need to add explicit type casts."),
-                parser_errposition(pstate, location)));
+       if (proc_call)
+           ereport(ERROR,
+                   (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
+                    errmsg("procedure %s is not unique",
+                           func_signature_string(funcname, nargs, argnames,
+                                                 actual_arg_types)),
+                    errhint("Could not choose a best candidate procedure. "
+                            "You might need to add explicit type casts."),
+                    parser_errposition(pstate, location)));
+       else
+           ereport(ERROR,
+                   (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
+                    errmsg("function %s is not unique",
+                           func_signature_string(funcname, nargs, argnames,
+                                                 actual_arg_types)),
+                    errhint("Could not choose a best candidate function. "
+                            "You might need to add explicit type casts."),
+                    parser_errposition(pstate, location)));
    }
    else
    {
@@ -591,6 +601,15 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
                             "after all regular arguments of the aggregate."),
                     parser_errposition(pstate, location)));
        }
+       else if (proc_call)
+           ereport(ERROR,
+                   (errcode(ERRCODE_UNDEFINED_FUNCTION),
+                    errmsg("procedure %s does not exist",
+                           func_signature_string(funcname, nargs, argnames,
+                                                 actual_arg_types)),
+                    errhint("No procedure matches the given name and argument types. "
+                            "You might need to add explicit type casts."),
+                    parser_errposition(pstate, location)));
        else
            ereport(ERROR,
                    (errcode(ERRCODE_UNDEFINED_FUNCTION),
index 0acea7bd8c7ce3881b728da2001bb6d821a6b54e..90e8f3c5ff0dc99f8d1106e5574e2f6635f98fb8 100644 (file)
@@ -1,8 +1,8 @@
 CALL nonexistent();  -- error
-ERROR:  function nonexistent() does not exist
+ERROR:  procedure nonexistent() does not exist
 LINE 1: CALL nonexistent();
              ^
-HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
+HINT:  No procedure matches the given name and argument types. You might need to add explicit type casts.
 CALL random();  -- error
 ERROR:  random() is not a procedure
 LINE 1: CALL random();