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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, Daniel Verite <daniel(at)manitou-mail(dot)org>, Erik Rijkers <er(at)xs4all(dot)nl>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, PostgreSQL <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers-owner(at)postgresql(dot)org
Subject: Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
Date: 2017-02-09 21:15:48
Message-ID: 5095.1486674948@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Corey Huinker <corey(dot)huinker(at)gmail(dot)com> writes:
> On Thu, Feb 9, 2017 at 3:13 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> IMO, an erroneous backslash command should have no effect, period.

> One way around this is to make the small change: commands with invalid
> expressions are ignored in interactive mode.

> Another way around it would be to ignore branching commands in interactive
> mode altogether and give a message like "branching commands not supported
> in interactive mode".

Uh, neither of those seem to be responding to my point. There is no case
in psql where a command with an invalid argument does something beyond
throwing an error. I do not think that \if is the place to start.

Having it act differently in interactive and noninteractive modes is an
even worse idea. AFAICS, the only real value of using \if interactively
is to test out something you are about to copy into a script. If we go
that route we're destroying the ability to test that way.

Basically, I think you need to start removing complexity (in the sense of
special cases), not adding more. I think Robert was saying the same
thing, though possibly I shouldn't put words in his mouth.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-02-09 21:24:49 Re: [PATCH] Rename pg_switch_xlog to pg_switch_wal
Previous Message Andres Freund 2017-02-09 21:08:46 Re: [PATCH] Rename pg_switch_xlog to pg_switch_wal