Jonathan Jacobson <> writes:
> The .psql_history file is naturally used by different DB connections
> (distinguished by a different combination of host + port + database + user).
> At least in my multi-database working environment, this leads sometimes to
> frustration because there are commands that cannot or should not be used by
> different connections.
> To solve this, psql could keep a separate command history file for each
> connection.
> I will be happy to make this my first contribution to PostgreSQL's code.
> What do you say?

Personally, I'd be strongly against that because I frequently *want*
to re-use the same command on different connections.  As an example,
comparing the behavior of the same command in different PG versions
(hence different postmasters) is an everyday task for me.

I can see that others might have different needs, but surely this
is going to be a use-case-specific requirement.

It's already possible to control which history file is used via psql's
HISTFILE variable and/or the PSQL_HISTORY environment variable.  Perhaps
you can solve your problem today by manipulating those?

One interesting point, if you wish to consider history as being
connection-specific, is what happens during a \c command.  Right
now the answer is "nothing" but you might wish it were different.

                        regards, tom lane

Sent via pgsql-hackers mailing list (
To make changes to your subscription:

Reply via email to