From: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com> |
---|---|
To: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
Cc: | Erik Rijkers <er(at)xs4all(dot)nl>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-10 18:41:57 |
Message-ID: | CADkLM=dXgQTRDsyjCUZCh9LGKbNAnxM2weVq9uO4E7LfJg5P2Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>
> Shouldn't there be some documentation changes to reflect the behavior on
> errors? A precise paragraph about that would be welcome, IMHO.
>
Oddly enough, the documentation I wrote hadn't addressed invalid booleans,
only the error messages did that.
The new behavior certainly warrants a mention, and I'll add that.
> Given that there is no more barking, then having some prompt indication
> that the code is inside a conditional branch becomes more important, so
> ISTM that there should be some plan to add it.
Yeah, prompting just got more important. I see a few ways to go about this:
1. Add a new prompt type, either %T for true (heh, pun) or %Y for
branching. It would print a string of chained 't' (branch is true), 'f'
(branch is false), 'z' (branch already had its true section). The depth
traversal would have a limit, say 3 levels deep, and if the tree goes more
than that deep, then '...' would be printed in the stead of any deeper
values. So the prompt would change through a session like:
command prompt is now
----------- ---------------------------------------
\echo bob '' = initial state, no branch going on at all
\if yes 't' = inside a true branch
\if no 'tf' = false inside a true
\endif 't' = back to just the true branch
\if yes 'tt'
\if yes 'ttt'
\if yes '...ttt' = only show the last 3, but let it be known that
there's at least one more'
\else '...ttz' = past the point of a true bit of this branch
2. The printing of #1 could be integrated into %R only in PROMPT_READY
cases, either prepended or appended to the !/=/^, possibly separated by a :
3. Like #2, but prepended/appended in all circumstances
4. Keep %T (or %Y), and reflect the state of pset.active_branch within %R,
a single t/f/z
5. Like #4, but also printing the if-stack depth if > 1
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiko Sawada | 2017-02-10 18:55:25 | Re: DROP SUBSCRIPTION and ROLLBACK |
Previous Message | Andres Freund | 2017-02-10 18:41:27 | Re: WIP: About CMake v2 |