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

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <stark(at)mit(dot)edu>, Erik Rijkers <er(at)xs4all(dot)nl>, Robert Haas <robertmhaas(at)gmail(dot)com>, Daniel Verite <daniel(at)manitou-mail(dot)org>, 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-26 07:47:22
Message-ID: alpine.DEB.2.20.1702260807540.10344@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Corey,

About v18: Patch applies, make check ok, psql tap tests ok.

ISTM that contrary to the documentation "\elif something" is not evaluated
in all cases, and the resulting code is harder to understand with a nested
switch and condition structure:

switch
default
read
if
switch

I wish (this is a personal taste) it could avoid switch-nesting on the
very same value. It should also conform to the documentation.

If there is no compelling reason for the switch-nesting, I would suggest
to move the read_boolean_expression before the swich, to deal with error
immediately there, and then to have just one switch.

Alternatively if the structure must really be kept, then deal with errors
in a first switch, read value *after* switch and deal with other errors
there, then start a second switch, and adjust the documentation
accordingly?

switch
errors
read
if
errors
// no error
switch

Also, the %R documentation has single line marker '^' before not executed
'@', but it is the reverse in the code.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-02-26 08:17:07 Re: ParallelFinish-hook of FDW/CSP (Re: Steps inside ExecEndGather)
Previous Message Robert Haas 2017-02-26 07:19:42 Re: case_preservation_and_insensitivity = on