Feature request: make cluster_name GUC useful for psql prompts - Mailing list pgsql-hackers

From Steve Crawford
Subject Feature request: make cluster_name GUC useful for psql prompts
Date
Msg-id CAEfWYyyeN3x+6qFJaCv64wpKw3SbwZ7XEdW_nhU3yjiuYyuNFA@mail.gmail.com
Whole thread Raw
Responses Re: Feature request: make cluster_name GUC useful for psql prompts  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
It's great that 9.5 has the new cluster_name variable as an available GUC.

It would be even better to make that GUC available for use in psql prompting escape sequences.

Prompting via sequences utilizing %M, %m and %> means the same cluster could be identified numerous ways (local, 127.0.0.1, 10.1.2.3, localhost, myserver.example.com, myserver, etc.) which is further exacerbated when pooling or port-forwarding is in play.

In the inverse case, when logging into a multiple servers and running psql, all the prompts might just say "local" despite all being different clusters.

Adding an escape sequence that references cluster_name would enable prompts to identify the cluster in a manner that is both consistent and distinct regardless of access path.

Potential issues/improvements:

What should the escape-sequence display if cluster_name is not set or the cluster is a pre-9.5 version. %M? %m?

In future server versions should there be a default for cluster_name if it is not set? If so, what should it be? Would the server canonical hostname + listen-port be reasonable?

Cheers,
Steve

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Initial release notes created for 9.6
Next
From: Masahiko Sawada
Date:
Subject: Re: Initial release notes created for 9.6