From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: i+pgbugs@avdd.tk
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6602: concurrent psql session clobbers history
Date: Wed, 25 Apr 2012 13:54:16 -0400
Message-ID: <9540.1335376456@sss.pgh.pa.us> (raw)
In-Reply-To: <1334866539.24114.10.camel@vanquo.pezone.net>
References: <E1SKoCB-00068b-5S@wrigleys.postgresql.org>
<20805.1334862057@sss.pgh.pa.us>
<1334866539.24114.10.camel@vanquo.pezone.net>
Peter Eisentraut <peter_e@gmx.net> writes:
> On tor, 2012-04-19 at 15:00 -0400, Tom Lane wrote:
>> i+pgbugs@avdd.tk writes:
>>> A concurrent psql session will overwrite the history of the first. This
>>> does not look good: a database tool causing me to lose my data!
>> Works okay for me. I suspect you need to take this up with whoever
>> packages libreadline for Ubuntu, because it's going to be libreadline's
>> problem not ours.
> It's probably actually using libedit for the history part.
[ after further research... ] Mmm, maybe. I can reproduce the
misbehavior on a Mac build using libedit. There is a relevant-looking
comment in psql's saveHistory function:
* On newer versions of libreadline, truncate the history file as
* needed and then append what we've added. This avoids overwriting
* history from other concurrent sessions (although there are still
* race conditions when two sessions exit at about the same time). If
* we don't have those functions, fall back to write_history().
A check of the configure output shows that Apple's libedit lacks
append_history(), so that the fallback code path is used. The phrasing
of this comment suggests that older versions of libreadline might be
lacking as well.
There's not a lot we can do about this issue when using a libreadline
or libedit that lacks the necessary support functions, I think.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, peter_e@gmx.net, i+pgbugs@avdd.tk
Subject: Re: BUG #6602: concurrent psql session clobbers history
In-Reply-To: <9540.1335376456@sss.pgh.pa.us>
References: <E1SKoCB-00068b-5S@wrigleys.postgresql.org> <20805.1334862057@sss.pgh.pa.us> <1334866539.24114.10.camel@vanquo.pezone.net> <9540.1335376456@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox