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

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Daniel Verite <daniel(at)manitou-mail(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, "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>, 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-04-14 00:08:59
Message-ID: alpine.DEB.2.20.1704140857050.16393@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> On Mon, Apr 3, 2017 at 3:32 PM, Daniel Verite <daniel(at)manitou-mail(dot)org> wrote:
>> In interactive mode, the warning in untaken branches is misleading
>> when \endif is on the same line as the commands that
>> are skipped. For instance:
>>
>> postgres=# \if false \echo NOK \endif
>> \echo command ignored; use \endif or Ctrl-C to exit current \if block
>> postgres=#
>>
>> From the point of view of the user, the execution flow has exited
>> the branch already when this warning is displayed.
>> Of course issuing the recommended \endif at this point doesn't work:
>>
>> postgres=# \endif
>> \endif: no matching \if
>>
>> Maybe that part of the message:
>> "use \endif or Ctrl-C to exit current \if block"
>> should be displayed only when coming back at the prompt,
>> and if the flow is still in an untaken branch at this point?
>
> Is this an open item, or do we not care about fixing it?

I would suggest that this is not important enough to block anything.

Otherwise, I agree that displaying this interactive message only when it
is pertinent is desirable, but this might change the underlying logic
significantly: it may mean holding somewhere a message to be shown at next
prompt, and being able to decide when to clear it.

There is also the question of what happens if there are multiple such
messages, should they all be shown? Only the first? The last? Should it
avoid repeats?

So I propose to call it a feature for now, especially that we do not
expect people to write a lot of one-liner multiple-backslash-commands in
interactive mode.

--
Fabien.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-04-14 00:38:13 Re: Quorum commit for multiple synchronous replication.
Previous Message Michael Paquier 2017-04-14 00:03:06 Re: logical replication and PANIC during shutdown checkpoint in publisher