Re: pgbench - add \if support

Поиск
Список
Период
Сортировка
От Vik Fearing
Тема Re: pgbench - add \if support
Дата
Msg-id 5f12699a-8ec0-8047-14fd-1d49c85f5a44@2ndquadrant.com
обсуждение исходный текст
Ответ на pgbench - add \if support  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: pgbench - add \if support  (Fabien COELHO <coelho@cri.ensmp.fr>)
Re: pgbench - add \if support  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список 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 по дате отправления:

Предыдущее
От: Fabien COELHO
Дата:
Сообщение: Re: pgbench - add \if support
Следующее
От: Fabien COELHO
Дата:
Сообщение: Re: pgbench - add \if support