Re: pgbench - add \if support

Fabien COELHO <coelho@cri.ensmp.fr>

From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Teodor Sigaev <teodor@sigaev.ru>
Cc: Vik Fearing <vik.fearing@2ndquadrant.com>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2018-01-12T18:29:38Z
Lists: pgsql-hackers
> Hm, isn't already commited when/case/then/else syntax do the same?

No, not strictly. The "CASE WHEN" is an if *within* an expression:

   \set i CASE WHEN condition THEN val1 ELSE val2 END

The \if is at the script level, like psql already available version, which 
can change what SQL is sent.

   \if condition
     SOME SQL
   \else
     OTHER SQL
   \endif

You could achieve the CASE semantics with some \if:

   \if condition
     \set i val1
   \else
     \set i val2
   \endif

But the reverse is not possible.

-- 
Fabien.


Commits

  1. Add \if support to pgbench