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-24 06:53:04
Message-ID: alpine.DEB.2.20.1702240729060.21598@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


About v17:

Patch applies, "make check" & psql "make check" ok.

>> ... '@' [...] I noticed that it takes precedence over '!'. [...]
>
> My reasoning was this: if you're in a false block, and you're not connected
> to a db, the \c isn't going to work for you until you get out of the false
> block, so right now being in a false block is a bigger problem than not
> being connected to a db. [...]

Ok.

>> It could be nice to keep test cases that show what may happen?
>
> Restored. It looks weird now, but it fixes the unterminated quoted
> string.

Typo "unterminted".

I think I found an issue while testing in interactive:

calvin=# \if false
calvin(at)# \if false
calvin(at)# \echo false-false
command ignored, use \endif or Ctrl-C to exit current branch.
calvin(at)# \endif
calvin=# \echo in false
in false

The \if within the \if false branch is not tallied properly? Am I missing
something?

Maybe more test cases should be added to check that nesting checks do work
properly?

>> Maybe the documentation could add some kind of warning about that?
>
> I changed the paragraph to

> Lines within false branches are parsed normally, however, any completed
> queries are not sent to the server, and any completed commands other
> than conditionals (<command>\if</command>, <command>\elif</command>,
> <command>\else</command>, <command>\endif</command>) are ignored.

I'm not sure about the ", however, " commas, but I'm sure that I do not
know English punctuation rules:-)

Maybe the sentence could be cut in shorter pieces.

I think that the fact that "if" commands are checked for proper nesting
could be kept in the explanation.

> There's no mention that psql variables AREN'T expanded, so the user has
> every expectation that they are.

Ok.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-02-24 06:59:01 Re: Poor memory context performance in large hash joins
Previous Message Ashutosh Sharma 2017-02-24 06:52:26 Re: Should we cacheline align PGXACT?