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

From Corey Huinker
Subject Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)
Date
Msg-id CADkLM=cBX9mb1FTymLrijmQFAoHjFZGNhphx6-V9u6jcGHzdTw@mail.gmail.com
Whole thread Raw
In response to Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
However I would say yes, it should provide some feedback... This means probably adding a new prompt substitution "%<something>". In the worst case, the prompt should reflect the current stack, or at least the top of the task...

We could just issue interactive-only warnings when:
- A user types a branching condition command which sets the branch inactive
- A user types a command or query when the current branch is inactive.

The warnings could be specific about state, something like:

psql session is now in an inactive \if branch. No queries will be executed and only branching commands (\if, \elif, \else, \endif) will be evaluated.

psql session is now in an inactive \elif branch. No queries will be executed and only branching commands (\if, \elif, \else, \endif) will be evaluated.

psql session is now in an inactive \else branch. No queries will be executed and only branching commands (\if, \endif) will be evaluated.


This could of course be done in addition to prompt changes, and is orthogonal to the CTRL-c  option. I'd like more input before moving forward on either of those, as they have a good chance to clobber other expected behaviors.

 

pgsql-hackers by date:

Previous
From: ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Date:
Subject: [HACKERS] [PATCH] Add tab completion for DEALLOCATE
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] [COMMITTERS] pgsql: Make psql's \set display variables in alphabetical order.