Re: extend pgbench expressions with functions

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: extend pgbench expressions with functions
Date: 2015-07-25 20:14:09
Message-ID: alpine.DEB.2.10.1507252202530.25082@sto
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello Heikki,

> As an initial list of functions, I'd suggest:
> abs(x)
> min(x, y, ...)
> max(x, y, ...)
> random_uniform(min, max)
> random_gaussian(min, max, threshold)
> random_exponential(min, max, threshold)
> Would that be enough to specify e.g. the
> As soon as we add more functions, the way they are documented needs to be
> reworked too; we'll need to add a table in the manual to list them.

Here is a v8 with "abs", "min", "max", "random", "gaussian" et

There is no expression typing, but expressions are evaluated and cast to
the expected type depending on what is needed (variables expect an int
value, function arguments are usually int but for threshold...).

There is an evalDouble function to evaluate double arguments for
gaussian & exponential thresholds.

There is a special "int" function which evaluates its argument as a double
and cast the result to an int, for testing purpose.

Variables are only int values, and functions only return ints.

There is no real doc, WIP...

Also included are a set of sql stuff I used for minimal tests.


Attachment Content-Type Size
pgbench-expr-abs-8.patch text/x-diff 16.0 KB
func-init.sql application/x-sql 104 bytes
func-reset.sql application/x-sql 19 bytes
func-show.sql application/x-sql 24 bytes
func.sql application/x-sql 438 bytes

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Bill Moran 2015-07-25 20:25:46 Re: Anyone working on the TOAST items on the TODO list?
Previous Message Tom Lane 2015-07-25 20:06:28 Re: Anyone working on the TOAST items on the TODO list?