Re: [HACKERS] pow support for pgbench

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Raúl Marín Rodríguez <rmrodriguez(at)carto(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] pow support for pgbench
Date: 2017-12-03 09:14:57
Message-ID: alpine.DEB.2.20.1712031007040.11574@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


>> The fact that the return type is not consistently of one type bothers
>> me. I'm not sure pgbench's expression language is a good place to
>> runtime polymorphism -- SQL doesn't work that way.
>
> Sure.
>
> Pg has a NUMERIC adaptative precision version, which is cheating, because it
> can return kind of an "int" or a "float", depending on whether there are
> digits after the decimal point or not.
>
> Pgbench does not have support for NUMERIC, just INT & DOUBLE, so the current
> version is an approximation of that.
>
> Now it is always possible to just do DOUBLE version, but this won't match SQL
> behavior either.

Another point I forgot: pgbench functions and operators are notably
interesting to generate/transform keys in tables, which are usually
integers, so having int functions when possible/appropriate is desirable,
which explain why I pushed for having an int version for POW.

Also, pgbench does not have a static typing model because variable types
are not declared "\set i ...", so the type is somehow "guessed" based on
the string values, although if in doubt it is always possible to convert
(with "int" & "double" functions).

So for me the philosophy is to have expression match SQL behavior when
possible, as closely as possible, but it is not an exact match.

--
Fabien.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2017-12-03 11:23:36 Re: [HACKERS] advanced partition matching algorithm for partition-wise join
Previous Message Pavel Stehule 2017-12-03 06:21:56 pg_dumpall -r -c try to drop user postgres