Re: [Patch] New psql prompt substitution %r (m = master, r = replica)

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, David Fetter <david(at)fetter(dot)org>
Subject: Re: [Patch] New psql prompt substitution %r (m = master, r = replica)
Date: 2016-08-18 01:36:20
Message-ID: 20160818013620.GA927541@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2016-08-18 01:55:07 Re: WIP: Barriers
Previous Message Andres Freund 2016-08-18 00:41:58 Re: Patch: initdb: "'" for QUOTE_PATH (non-windows)