On 8/18/16 10:05 AM, Alvaro Herrera wrote:
Bash has PROMPT_COMMAND, which is executed prior to issuing each prompt.
What about introducing such a feature into psql? Then the \gset command
you had in your first post could be used to set the variable correctly
just before each prompt.
As someone
Aleksander Alekseev wrote:
> Peter has a good point that in general case it's more complicated than
> just master or replica. I also agree with David that what actually
> would be nice to have is a some syntax that allows user to execute
> arbitrary commands before displaying a prompt. This way us
Hello, Alvaro.
> ... this is terrible. Not only because it's a lot of code dependent
> on an external tool which will be rather heavyhanded for something
> that should probably be very lightweight, but also because the code
> itself is (no offense) an unreadable mess.
>
> I think your general id
Aleksander Alekseev wrote:
> $ cat ~/.psqlrc
> select (case when pg_is_in_recovery() then 'r' else 'm' end) as mor
> \gset
>
> \set PROMPT1 '%p (%:mor:) =# '
Okay, this seems moderately reasonable, but ...
> Besides I figured out that replica promotion case could also be properly
> handled wit
Thank you everyone for your replies!
I did some research and apparently the is no need in any patch. As
David pointed out what I did could be easily done using \gset:
```
$ cat ~/.psqlrc
select (case when pg_is_in_recovery() then 'r' else 'm' end) as mor
\gset
\set PROMPT1 '%p (%:mor:) =# '
```
On Fri, Aug 12, 2016 at 12:51 AM, Tom Lane wrote:
> Peter Eisentraut writes:
>> On 8/11/16 6:04 AM, Aleksander Alekseev wrote:
>>> Suggested patch introduces an %r substitution in psql's prompt. This
>>> substitution allows to display whether user is connected to master or
>>> replica right in a
On Thu, Aug 11, 2016 at 01:04:19PM +0300, Aleksander Alekseev wrote:
> Hello.
>
> Suggested patch introduces an %r substitution in psql's prompt. This
> substitution allows to display whether user is connected to master or
> replica right in a prompt.
This is a neat idea, but there are some issue
Peter Eisentraut writes:
> On 8/11/16 6:04 AM, Aleksander Alekseev wrote:
>> Suggested patch introduces an %r substitution in psql's prompt. This
>> substitution allows to display whether user is connected to master or
>> replica right in a prompt.
> In the near future, there will (probably) be a
On 8/11/16 6:04 AM, Aleksander Alekseev wrote:
> Suggested patch introduces an %r substitution in psql's prompt. This
> substitution allows to display whether user is connected to master or
> replica right in a prompt.
In the near future, there will (probably) be a lot more variants about
what it
Hello.
Suggested patch introduces an %r substitution in psql's prompt. This
substitution allows to display whether user is connected to master or
replica right in a prompt.
Usage example:
```
$ cat ~/.psqlrc
\set PROMPT1 '%p (%r) =# '
$ psql -p 5432
psql (9.6beta4)
Type "help" for help.
20638
10 matches
Mail list logo