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

From: Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: [Patch] New psql prompt substitution %r (m = master, r = replica)
Date: 2016-08-11 10:04:19
Message-ID: 20160811130419.4ad7afd5@e733
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

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 (m) =# \q

$ psql -p 5433
psql (9.6beta4)
Type "help" for help.

20647 (r) =# \q
```

Currently I'm working on some functionality involving master-slave
replication. Sometimes I accidentally connect to a master instead of
replica and vice versa. Presence of functionality described above would
make my work much more convenient.

Hopefully there are other people in PostgreSQL community who feel that
way.

--
Best regards,
Aleksander Alekseev

Attachment Content-Type Size
prompt-r-substitution-v1.patch text/x-patch 4.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shay Rojansky 2016-08-11 10:07:52 Re: Slowness of extended protocol
Previous Message Artur Zakirov 2016-08-11 09:46:28 Re: Bug in to_timestamp().