Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless) - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)
Date
Msg-id alpine.DEB.2.20.1702240729060.21598@lancre
Whole thread Raw
In response to Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)  (Corey Huinker <corey.huinker@gmail.com>)
Responses Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)  (Corey Huinker <corey.huinker@gmail.com>)
List 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@#   \if false calvin@#     \echo false-false   command ignored, use \endif or Ctrl-C to exit
currentbranch. calvin@#   \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.



pgsql-hackers by date:

Previous
From: Ashutosh Sharma
Date:
Subject: Re: [HACKERS] Should we cacheline align PGXACT?
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Poor memory context performance in large hash joins