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

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

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "David E(dot) Wheeler" <david(at)kineticode(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5616: psql Doesn't Change Log files on \c
Date: 2010-08-13 08:38:06
Message-ID: 20100813083806.GA9068@depesz.com (view raw or flat)
Thread:
Lists: pgsql-bugs
On Thu, Aug 12, 2010 at 06:33:13PM -0400, Tom Lane wrote:
> "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.)

I think it would be enough to track previous and current database name,
and re-do the history code on change.

depesz

-- 
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz(at)depesz(dot)com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

In response to

Responses

pgsql-bugs by date

Next:From: Heikki LinnakangasDate: 2010-08-13 12:01:23
Subject: Assertion failure from plan cache invalidation
Previous:From: Fujii MasaoDate: 2010-08-13 01:21:07
Subject: Re: Re: BUG #5602: Recovering from Hot-Standby file backup leads to the currupted indexes

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