Re: pgbench - add \if support - Mailing list pgsql-hackers

From Vik Fearing
Subject Re: pgbench - add \if support
Date
Msg-id 5f12699a-8ec0-8047-14fd-1d49c85f5a44@2ndquadrant.com
Whole thread Raw
In response to pgbench - add \if support  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: pgbench - add \if support
Re: pgbench - add \if support
List pgsql-hackers
On 11/25/2017 10:33 PM, Fabien COELHO wrote:
> 
> This patch adds \if support to pgbench, similar to psql's version added
> in March.
> 
> This patch brings a consistent set of features especially when combined
> with two other patches already in the (slow) CF process:
> 
>  - https://commitfest.postgresql.org/10/596/ .. /15/985/
>    adds support for booleans expressions (comparisons, logical
>    operators, ...). This enhanced expression engine would be useful
>    to allow client-side expression in psql.
> 
>  - https://commitfest.postgresql.org/10/669/ .. /15/669/
>    adds support for \gset, so that pgbench can interact with a database
>    and extract something into a variable, instead of discarding it.
> 
> This patch adds a \if construct so that an expression on variables,
> possibly with data coming from the database, can change the behavior of
> a script.

I have given this patch a pretty good shake and I'm happy with it.  I
did not test it with the other two patches, only on its own.

> A partial evaluation is performed to detect structural errors (eg
> missing endif, else after else...) when the script is parsed, so that
> such errors cannot occur when a script is running.

Very good.

> A new automaton state is added to quickly step over false branches.

This one took me a little while to understand while reading the patch,
but mostly because of how diff doesn't handle moving things around.

> TAP tests ensure reasonable coverage of the feature.

And the documentation seems sufficient, as well.

It's a shame this feature uses \elif instead of \elsif to be closer to
plpgsql, but I suppose this ship already sailed when psql chose \elif,
and I think it is correct that this patch follows psql.

Marking as ready for committer.
-- 
Vik Fearing                                          +33 6 46 75 15 36
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support


pgsql-hackers by date:

Previous
From: Fabien COELHO
Date:
Subject: Re: pgbench - add \if support
Next
From: Fabien COELHO
Date:
Subject: Re: pgbench - add \if support