Re: Multiple psql history files

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jonathan Jacobson <jonjac(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Multiple psql history files
Date: 2016-10-18 16:56:27
Message-ID: CAKFQuwaxRAmUZ-3XDtM14XKjnAR41evRcBCzLC35ZYguUY2UVw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 18, 2016 at 9:45 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Jonathan Jacobson <jonjac(at)gmail(dot)com> 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?
>
> 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.
>

​Just to clarify/confirm a point inferred from the docs...

If you place "\set HISTFILE​ ~/.psql_history- :DBNAME
"


​into your .psqlrc file then when you perform a "\c" the .psqlrc file is
re-read and the ​new value for DBNAME is used to generate a new history
file name.

​As Julien pointed out cross-thread this really does seem to be the best
place to implement such logic - though shell functions and aliases can be
used to some good effect as well.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-10-18 17:21:38 Re: Multiple psql history files
Previous Message Tom Lane 2016-10-18 16:45:20 Re: Multiple psql history files