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

From Fabien COELHO
Subject Re: pgbench - add \if support
Date
Msg-id alpine.DEB.2.20.1801121920140.15795@lancre
Whole thread Raw
In response to Re: pgbench - add \if support  (Teodor Sigaev <teodor@sigaev.ru>)
Responses Re: pgbench - add \if support
List 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.


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] Parallel tuplesort (for parallel B-Tree index creation)
Next
From: David Fetter
Date:
Subject: Re: CREATE ROUTINE MAPPING