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

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Fabien COELHO" <coelho(at)cri(dot)ensmp(dot)fr>,"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>,"Robert Haas" <robertmhaas(at)gmail(dot)com>,"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-03 19:32:17
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


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

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?

Best regards,
Daniel Vérité
PostgreSQL-powered mailer:
Twitter: @DanielVerite

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Sven R. Kunze 2017-04-03 19:41:54 Re: [PATCH] few fts functions for jsonb
Previous Message Andres Freund 2017-04-03 19:31:59 Re: parallel explain analyze support not exercised