From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Dominique Devienne <ddevienne(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Identifying function-lookup failures due to argument name mismatches |
Date: | 2025-08-25 02:43:49 |
Message-ID: | EB6ABA47-7322-4B17-B206-A7E428D8693B@gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On Aug 25, 2025, at 02:47, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Here is a v4 with some additional bike-shedding on the error texts.
> In particular, I decided that it was worth expending an additional
> flag bit so that we could reliably distinguish "There is no function
> of that name" from "A function of that name exists, but it is not in
> the search_path". (Since FuncnameGetCandidates is already searching
> the entire set of functions matching the given name, it doesn't take
> any extra work to know that there's a match outside the search path.)
> I rephrased a couple of the other messages too, but without any
> substantive logic change.
>
I tested various error cases, all got proper error messages. So, I think this patch has significantly improved the situation.
I just have a tiny comment. In func_lookup_failure_details(), there are a lot of duplicate code like:
```
if (proc_call)
return errdetail("A procedure of that name exists, but it is not in the search_path.");
else
return errdetail("A function of that name exists, but it is not in the search_path.”);
```
The if-else is just to distinguish “procedure” and “function”, rest of words are duplicated.
Can we avoid the duplication in a way like:
```
static int
func_lookup_failure_details(int fgc_flags, List *argnames, bool proc_call)
{
const char *func_kind = proc_call ? "procedure" : "function";
/*
if (proc_call)
return errdetail("There is no procedure of that name.");
else
return errdetail("There is no function of that name.");
*/
return errdetail("There is no %s of that name.", func_kind);
```
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
From | Date | Subject | |
---|---|---|---|
Next Message | 邱宇航 | 2025-08-25 02:46:43 | Re: Memory leak of SMgrRelation object on standby |
Previous Message | Thomas Munro | 2025-08-25 02:42:35 | Re: Non-reproducible AIO failure |