Re: extend pgbench expressions with functions

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: extend pgbench expressions with functions
Date: 2015-07-23 08:31:38
Message-ID: 55B0A66A.8030403@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03/06/2015 11:41 AM, Fabien COELHO wrote:
> This patch extends pgbench expression with functions. Currently only one
> "abs" function is added. The point is rather to bootstrap the
> infrastructure for other functions (such as hash, random variants...) to
> be added later.

I think it would actually be good to add at least some of those other
functions in the initial patch. The infrastructure that this patch adds
only supports arguments with a single argument, so it won't get us very
far. Also, will we need non-integer (e.g. string, numeric, whatever)
arguments for the functions? How about other datatypes for variables in
general? Perhaps not, or if we do that can be a separate patch, but it's
something to keep in mind. The pgbench script language is evolving into
a full-blown Turing-complete programming language...

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.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2015-07-23 08:52:33 Re: WAL logging problem in 9.4.3?
Previous Message Heikki Linnakangas 2015-07-23 08:06:50 Re: Idea: closing the loop for "pg_ctl reload"