Skip site navigation (1) Skip section navigation (2)

Re: BUG #5616: psql Doesn't Change Log files on \c

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5616: psql Doesn't Change Log files on \c
Date: 2010-08-12 22:33:13
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
"David E. Wheeler" <david(at)kineticode(dot)com> writes:
> I have this in my .psqlrc:
>     \set HISTFILE ~/.psql_history- :DBNAME
> This is great, except when I change databases in a session:

>     % psql foo
>     foo % \c bar
>     You are now connected to database "bar".
>     SELECT true;

> The last statement will be logged to ~/.psql_history-foo when it should go
> to ~/.psql_history-bar.

I don't think this is a bug.  The history file is read at psql startup
and written out (to the same file name) at exit.  Those operations are
quite expensive, so it would be insane to do them after every backslash
command on the off chance that somebody was expecting to have changed
the effective name of the history file.  (Aside from the cost, this
would greatly increase the race condition hazards from concurrent psql
sessions trying to write the file at the same time.)

			regards, tom lane

In response to


pgsql-bugs by date

Next:From: Leo ShklovskiiDate: 2010-08-13 00:01:17
Subject: BUG #5617: pg_restore behaves unexpectedly on 'invalid' command line
Previous:From: David E. WheelerDate: 2010-08-12 22:05:34
Subject: BUG #5616: psql Doesn't Change Log files on \c

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group