Add %r substitution for psql prompts to show recovery status

Поиск
Список
Период
Сортировка
От Ian Barwick
Тема Add %r substitution for psql prompts to show recovery status
Дата
Msg-id 3a40f835-116d-0f95-aede-d5236337bbf0@2ndquadrant.com
обсуждение исходный текст
Ответы Re: Add %r substitution for psql prompts to show recovery status  (Robert Haas <robertmhaas@gmail.com>)
Re: Add %r substitution for psql prompts to show recovery status  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-hackers
Hi

Attached patch adds an "%r" substitution for psql prompts to show
recovery status. Specifically it displays an "&" (ampersand) if
the server is in recovery, otherwise nothing, e.g.:

     postgres=&# SELECT foo;

Why is this useful? Because I find myself messing about with replication
clusters a lot, and it would be nice to have an at-a-glance confirmation
whether I'm connected to a standby or not.

Why an ampersand? Because it's not used for any other prompts, and
it can be used as a mnemonic: "and" -> "st'and'by" (clutching at
straws a bit there I admit, but best I could come up with).

Note this substitution sends a "pg_is_in_recovery()" query to the server
each time it's encountered; unless there's something I'm overlooking I
think that's the only reliable way to determine current recovery status.
A possible alternative would be only to check the status each time a new
database connection is made, but that wouldn't catch the case where the
server has been promoted.

Will submit to next commitfest.


Regards

Ian Barwick

-- 
  Ian Barwick                   http://www.2ndQuadrant.com/
  PostgreSQL Development, 24x7 Support, Training & Services

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Masahiko Sawada
Дата:
Сообщение: Re: User defined data types in Logical Replication
Следующее
От: Robert Haas
Дата:
Сообщение: Re: pgsql: When VACUUM or ANALYZE skips a concurrently dropped table,log i