public inbox for [email protected]
help / color / mirror / Atom feedFrom: Bzzzz <[email protected]>
To: [email protected]
Subject: Re: Unable to call an overloaded UDF
Date: Fri, 13 May 2022 01:57:18 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <LV2PR21MB318335C4C61C2EB2FF6E177BE3CB9@LV2PR21MB3183.namprd21.prod.outlook.com>
References: <LV2PR21MB318335C4C61C2EB2FF6E177BE3CB9@LV2PR21MB3183.namprd21.prod.outlook.com>
On Thu, 12 May 2022 23:38:29 +0000
Hanefi Onaldi <[email protected]> wrote:
> Hello,
Hi,
> I have created 2 functions with the same name, and I am unable to
> call one of them. The first one does not have any parameters, and the
> second one has a single parameter with a default value. The error
> message I get makes sense to me, however the hint is not so helpful
> as I do not see any way I can do a type cast that will make Postgres
> call the function without any parameters in the definition.
>
> Is there a way to make this work? Can this be a bug that needs
> fixing, or is it a known and intended feature?
>
>
> Function definitions:
>
> CREATE FUNCTION f() RETURNS int as $$ SELECT 1 $$ LANGUAGE SQL;
> CREATE FUNCTION f(param int DEFAULT 1) RETURNS int as $$ SELECT param
> $$ LANGUAGE SQL;
>
>
> Error message after I ran a simple query:
>
> postgres # SELECT f();
> ERROR: 42725: function f() is not unique
> LINE 1: SELECT f();
> ^
> HINT: Could not choose a best candidate function. You might need to
> add explicit type casts. LOCATION: ParseFuncOrColumn,
> parse_func.c:577
Looks logical to me, as the 2nd Fn has a _facultative_ parm, hence both
Fn are "equal" as they both can be called without any parm, remove the
"DEFAULT 1" part of the 2nd Fn to see if you still get an error, or if
you really need this default, move one of those into another schema and
call it by it's qualified name : schema_name.Fn_name(…)
Jean-Yves
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Unable to call an overloaded UDF
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox