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=dPkC_VCfVtNN+avGLAYpYUR+pkYxcrHvXxth3X0BcXbg@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>)
List pgsql-hackers
On Sat, Feb 11, 2017 at 3:48 PM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:

Just realized that '?' means "unknown transactional status" in %x. That
might cause confusion if a person had a prompt of %x%R. Is that enough
reason to pick a different cue?

Argh.

"\?\.?[tfz]" seems distinctive enough. Note that %R uses "'=-*^!$( and %x uses *!?, which means that they already share 2 characters, so adding ? does not seem like a big issue if it was not one before.

Otherwise, maybe "&" or "%", but it is less about a condition.

Fair enough, it shouldn't be too confusing then.

The get_prompt() function can see the global pset, obviously, but can't see the scan_state, where the if-stack currently resides. I could give up on the notion of a per-file if-stack and just have one in pset, but that might make life difficult for whomever is brave enough to tackle \while loops. Or I could give pset a pointer to the current if-stack inside the scan_state, or I could have pset hold a stack of stacks. Unsure which way would be best. 

pgsql-hackers by date:

Previous
From: Andreas Karlsson
Date:
Subject: Re: [HACKERS] REINDEX CONCURRENTLY 2.0
Next
From: Greg Stark
Date:
Subject: Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)