Re: [HACKERS] pow support for pgbench - Mailing list pgsql-hackers

From Raúl Marín Rodríguez
Subject Re: [HACKERS] pow support for pgbench
Date
Msg-id CAM6_UM5SCAicrDoHeQ1CcHc8D1M6vV-T-NQVZjYonjCETqw=pA@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] pow support for pgbench  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: [HACKERS] pow support for pgbench  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
Hi Fabien,

Sorry for the confusion, I wasn't aware that SQL pow changed types depending on
the input value.

I've modified the function to match more closely the behaviour of SQL, except
that 0^(negative) returns 'double inf'. Do you think there is any value in
raising an error instead?


On Mon, Nov 6, 2017 at 2:12 PM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:

Hello Raúl,

I've fixed the documentation and added an ipow function that handles both
positive and negative ints, having 0^0 == 1 and 0^(negative) == PG_INT64_MAX
since that's what my glibc math.h pow() is returning.

From the comment:

 * For exp < 0 return 0 except when the base is 1 or -1

I think that it should do what POW does in psql, i.e.:

 fabien=# SELECT POW(2, -2); # 0.25

that is if exp < 0 the double version should be used, it should
not return 0.

Basically the idea is that the pgbench client-side version should behave the same as the SQL version.

--
Fabien.



--
Raúl Marín Rodríguez
carto.com

Attachment

pgsql-hackers by date:

Previous
From: Paul Ramsey
Date:
Subject: Re: [HACKERS] Parallel Plans and Cost of non-filter functions
Next
From: Stephen Frost
Date:
Subject: Re: [HACKERS] Early locking option to parallel backup