Waiting for 9.1 – \conninfo in psql

On 20th of July, Robert Haas committed (and later committed change to it) patch which adds another \* command to psql:

Log Message:
-----------
Add \conninfo command to psql, to show current connection info.
 
David Christensen. Reviewed by Steve Singer.  Some further changes by me.

Log message seems to be clear, so just let's show it:

$ \conninfo
You are connected to database "depesz" via local socket at port "5900" as user "depesz".

This might be really useful for people who are using a lot of different databases – just to avoid running wrong sql at wrong database.

On the other hand – very similar thing was possible to get earlier, with simple addition to $HOME/.psqlrc:

\set PROMPT1 '(%n@%M:%>) %`date +%H:%M:%S` [%/] \n%x$ '

Thanks to this my prompt looks like this:

(depesz@[local]:5900) 14:57:43 [depesz]
$

So I have all the necessary information without even typing another command. Anyway – the addition is nice in case you can't (or don't want to) customize your environment.