Re: PSQL commands: \quit_if, \quit_unless

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, PostgreSQL <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PSQL commands: \quit_if, \quit_unless
Date: 2016-11-29 12:10:06
Message-ID: alpine.DEB.2.20.1611291254040.19314@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Pavel,

> Now, the psql statements are designed do nothing in syntax error. I am not
> sure about be more strict in this case. I see strong advantages - but it
> can be little bit different than current behave.

Indeed, an error on a conditional construct should stop the script, which
is slightly different that "go on whatever", which is okay in the
interactive mode.

I do not see that as an issue, just as features which are more interactive
vs script oriented and behave accordingly: typing a \if in interactive
does not makes much sense, because you have tested something is there, so
you know the answer and can act directly, so there is no point using a
condition.

>> \if ! :has_xxx_feature
>
> I prefer the commands instead symbols - the parsing and processing
> symbols should be more complex than it is now. A psql parser is very
> simple - and any complex syntax enforces lot of code. \if_not

My 0,02 €, which is just a personal opinion:

I think that handling manually "!/not" would be worth the effort rather
than having two commands, especially if the boolean expression syntax may
be extended some day and the negative if would become obsolete.

If there is a negative condition syntax, I would slightly prefer \ifnot to
\if_not or worse \unless. I would disaprove strongly of \unless because it
looses the clear symmetry with a closing \fi.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2016-11-29 12:56:26 tiny psql doc inconsistency
Previous Message Amos Bird 2016-11-29 11:38:11 Re: make default TABLESPACE belong to target table.