Re: pow support for pgbench
rmrodriguez@carto.com
From: Raúl Marín Rodríguez <rmrodriguez@carto.com>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>,
Michael Paquier <michael.paquier@gmail.com>, PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Date: 2017-11-06T14:28:30Z
Lists: pgsql-hackers
Attachments
- pgbench_pow_v4_pgbench-more-ops-funcs-14.patch (text/x-patch) patch v4
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
Commits
-
Add pow(), aka power(), function to pgbench.
- 7a727c180aa3 11.0 landed
-
pgbench: Support double constants and functions.
- 86c43f4e22c0 9.6.0 cited