Re: psql: customizable readline history filename

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andreas Seltenreich <seltenreich(at)gmx(dot)de>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: psql: customizable readline history filename
Date: 2005-06-10 15:46:41
Message-ID: 200506101546.j5AFkf626137@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Andreas Seltenreich wrote:
> Hi,
>
> the following patch makes the filename used to store the readline
> history customizable through a variable named HISTFILE, analogous to
> psql's already implemented HISTCONTROL and HISTSIZE variables, and
> bash's HISTFILE-Variable.
>
> The motivation was to be able to get psql to maintain separate
> histories for separate databases. This is now easily achievable
> through a line like the following in ~/.psqlrc:
>
> \set HISTFILE ~/.psql_history- :DBNAME

I have applied your patch with slight modifications; new version
attached.

Win32 doesn't have tilde expansion, so your idea of using
"~/.psql_history" as a default would not work --- I had to keep the
get_home_path() code in there.

I decided to make psql_history a file static variable, so we would not
have to recompute its value when writing the history file.

I noticed your documentation example had a space before :DBNAME --- I
removed the space.

You had the idea of not saving the history on exit if HISTFILE is not
set. I don't think we have community agreement on that change, and I
bet we wouldn't get it. (I have removed your documentation mention of
this.) I think setting HISTSIZE to zero has that effect already if
people want it.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 3.6 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2005-06-10 15:58:09 Re: plperl: enable UTF-8 support
Previous Message Dave Page 2005-06-10 14:23:20 Re: Server instrumentation