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