Re: add modulo (%) operator to pgbench - Mailing list pgsql-hackers

From Robert Haas
Subject Re: add modulo (%) operator to pgbench
Date
Msg-id CA+TgmobhMsRtmQ6vZPGM+_Z2OqOsVoMc2TB1SRmsLbvOrLVGJg@mail.gmail.com
Whole thread Raw
In response to Re: add modulo (%) operator to pgbench  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: add modulo (%) operator to pgbench  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
On Wed, Aug 6, 2014 at 3:22 PM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:
>> Maybe we ought to break down and support a real expression syntax.
>> Sounds like that would be better all around.
>
> Adding operators is more or less orthogonal with providing a new expression
> syntax. I'm not sure that there is currently a crying need for it (a
> syntax). It would be a significant project. It would raise the question
> "where to stop"... And I just really need a few more functions/operators
> which can be fitted in the current implementation quite easily.

Writing a simple expression parser for pgbench using flex and bison
would not be an inordinately difficult problem.  And it would let you
add abs() and ?: and thereby avoid the need to hard-code multiple
versions of the modulo operator in the patch.  The fact that you're
agonizing about which modulo to add is a sign that the language is too
impoverished to let you do anything non-trivial.  That's why C only
has one modulo operator: as the patch demonstrates, the differences
between the version can be patched over with a very short C
expression.  If we had real expressions in pgbench, you could do the
same thing there.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Join push-down support for foreign tables
Next
From: Bruce Momjian
Date:
Subject: Re: Memory Alignment in Postgres