Re: pgbench - add \if support

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Teodor Sigaev <teodor(at)sigaev(dot)ru>
Cc: Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgbench - add \if support
Date: 2018-01-12 18:29:38
Message-ID: alpine.DEB.2.20.1801121920140.15795@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2018-01-12 18:50:13 Re: CREATE ROUTINE MAPPING
Previous Message Robert Haas 2018-01-12 18:28:49 Re: [HACKERS] Parallel tuplesort (for parallel B-Tree index creation)