Re: [Patch] New psql prompt substitution %r (m = master, r = replica) - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: [Patch] New psql prompt substitution %r (m = master, r = replica)
Date
Msg-id 20160818013620.GA927541@alvherre.pgsql
Whole thread Raw
In response to Re: [Patch] New psql prompt substitution %r (m = master, r = replica)  (Aleksander Alekseev <a.alekseev@postgrespro.ru>)
Responses Re: [Patch] New psql prompt substitution %r (m = master, r = replica)  (Aleksander Alekseev <a.alekseev@postgrespro.ru>)
List pgsql-hackers
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 without any patches. In case anyone is interested here is a
> brief description of a solution.
> 
> ~/.bash_profile:

... 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 idea for the feature is a good one, even if the
patch you submitted isn't a good implementation.  Not sure a real one
is worth the effort, though.  I don't think Peter's comment that more
roles than master/replica are possible is a showstopper: that's already
going to be an issue for things like ALTER TRIGGER ENABLE REPLICA and
the like, I suppose.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Pluggable storage
Next
From: Michael Paquier
Date:
Subject: Re: Anyone want to update our Windows timezone map?