Subject Re: [firebird-support] Firebird 3: formal declaration of ABS internal function, is it polymorphic?
Author Mark Rotteveel
On 30-1-2018 12:24, jonatan.lauritsen@... [firebird-support] wrote:
> For DB upgrade (from 1.5 to 3.0) I need to define custom internal
> function like this:
> create or alter function F_ABS (
>     VAR_1 double precision)
> returns integer
> AS
> declare variable result double precision;
> begin
>   result = abs(var_1);
>   return result;
> end
> But I am confused. My experiments assert that ASB internal function is
> polymorphic - it returns BIGINT for BIGINT argument and DOUBLE PRECISION
> for DOUBLE PRECISION arguments, it can be tricky to determine the return
> type if string arguments is given (and implicit conversion occurs).
> I would like that F_ABS has this polymorphic nature of ABS. How should I
> declare F_ABS to have this polymorphic nature?

As far as I'm aware, that is simply not possible. UDFs (and the new
Firebird 3 PSQL functions) must explicitly declare their type, while
built-ins have access to additional type information at execution time.

Mark Rotteveel