]> git.ipfire.org Git - thirdparty/postgresql.git/commit
psql: Add %i prompt escape to indicate hot standby status.
authorFujii Masao <fujii@postgresql.org>
Tue, 3 Feb 2026 01:03:19 +0000 (10:03 +0900)
committerFujii Masao <fujii@postgresql.org>
Tue, 3 Feb 2026 01:03:19 +0000 (10:03 +0900)
commitdddbbc253b923ef27f724c6abb5a6a39e1254d54
tree986e35da7304e960ce98544e16d29f9fd1af4128
parent4a99ef1a0d11ed464295515635a44aad1b000691
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.jones@uni-muenster.de>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Greg Sabino Mullane <htamfids@gmail.com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Discussion: https://www.postgresql.org/message-id/flat/016f6738-f9a9-4e98-bb5a-e1e4b9591d46@uni-muenster.de
doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/prompt.c