Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Daniel Verite <daniel(at)manitou-mail(dot)org>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Greg Stark <stark(at)mit(dot)edu>, Erik Rijkers <er(at)xs4all(dot)nl>, Robert Haas <robertmhaas(at)gmail(dot)com>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, PostgreSQL <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
Date: 2017-03-30 16:22:23
Message-ID: alpine.DEB.2.20.1703301812100.18789@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Tom,

>> pgbench (well, at least if I succeed in getting boolean expressions and
>> setting variables, which is just a maybe), but this kind of if in the
>> middle of expression does not make much sense for a pgbench script where
>> "if" must be evaluated at execution time, not parse time.
>
> Well, it's not really clear to me why that would be true.

For example, how can you PREPARE a possibly combinatorial thing?

SELECT
\if ... XX \else YY \endif
FROM
\if ... ZZ \else WW \endif
WHERE
\if ... AA \else BB \endif
;

Or the kind of operation:

\if ...
SELECT *
\else
DELETE
\endif
FROM table WHERE condition;

Even the structure can be changed somehow:

SELECT
\if ...
1 ;
SELECT 2
\endif
;

> If it actually is impossible to give pgbench equivalent behavior, we'll
> just have to live with the discrepancy,

Yep.

> but ISTM it could probably be made to work.

Even if it could somehow, I do not see it as a useful feature for pgbench.
I also lack a good use case for psql for this feature.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2017-03-30 16:45:04 Re: pgsql: Allow vacuums to report oldestxmin
Previous Message Aleksander Alekseev 2017-03-30 16:12:36 Re: WIP: Covering + unique indexes.