pgsql: psql: Add %i prompt escape to indicate hot standby status.

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: psql: Add %i prompt escape to indicate hot standby status.
Date: 2026-02-03 01:04:35
Message-ID: E1vn4qI-000oZt-2U@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

psql: Add %i prompt escape to indicate hot standby status.

This commit introduces a new prompt escape %i for psql, which shows
whether the connected server is operating in hot standby mode. It
expands to standby if the server reports in_hot_standby = on, and
primary otherwise.

This is useful for distinguishing standby servers from primary ones
at a glance, especially when working with multiple connections in
replicated environments where libpq's multi-host connection strings
are used.

Author: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
Reviewed-by: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Andreas Karlsson <andreas(at)proxel(dot)se>
Discussion: https://www.postgresql.org/message-id/flat/016f6738-f9a9-4e98-bb5a-e1e4b9591d46(at)uni-muenster(dot)de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/dddbbc253b923ef27f724c6abb5a6a39e1254d54

Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml | 17 +++++++++++++++++
src/bin/psql/prompt.c | 18 ++++++++++++++++++
2 files changed, 35 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-02-03 02:15:04 pgsql: Release synchronous replication waiters immediately on configura
Previous Message Melanie Plageman 2026-02-02 22:46:15 pgsql: Fix flakiness in the pg_visibility VM-only vacuum test by using