Re: libedit history seems to be misbehaving / broken

From: Rudolph Froger <rudolphfroger(at)dreamsolution(dot)nl>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: libedit history seems to be misbehaving / broken
Date: 2025-01-22 08:05:23
Message-ID: CALaJbqz262ax=t8W32oujxM+5Kn7Ov5nT+rZgaJn70CbRroFfQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 22 Jan 2025 at 08:54, Bruce Momjian <bruce(at)momjian(dot)us> wrote:

> On Sun, Oct 27, 2024 at 09:07:44PM +0100, Tomas Vondra wrote:
> > On 10/27/24 20:03, Tom Lane wrote:
> > > FWIW, I don't observe any particular misbehavior with the very ancient
> > > libedit that macOS ships. On Fedora 39, I notice something related to
> > > what you say: it seems like the "\q" ending a session gets repeated
> > > into .psql_history by the next session. I'm surprised that it's not
> > > exactly the same as your results though, because it seems to be the
> > > same source version:
> > >
> > > $ rpm -q libedit
> > > libedit-3.1-53.20240808cvs.fc39.x86_64
> > >
> >
> > That's probably because I usually terminate psql by Ctrl-D, not by
> > typing "\q". But yeah, if I use "\q" it gets added twice.
> >
> > > Didn't try the too-many-lines behavior, but it looks like that
> > > is implemented totally by history_truncate_file(), so if that's
> > > busted it's surely their fault.
> > >
> >
> > Sounds likely. What surprises me a bit, I haven't found any reports of
> > particularly similar bugs ... I'd have expected other people to hit this
> > too, but who knows.
>
> I wonder if our previous libedit workarounds aren't needed anymore and
> are causing the bugs.
>

I'm experiencing a similar behaviour. Indeed adding _HiStOrY_V2_ to the top
of the .psql_history file fixes the issue, until libedit (?) strips it off
again.

---

Rudolph Froger

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Yura Sokolov 2025-01-22 08:22:44 Re: [RFC] Lock-free XLog Reservation from WAL
Previous Message Japin Li 2025-01-22 07:54:32 Re: [RFC] Lock-free XLog Reservation from WAL