Re: BUG #14287: psql_history gets wiped out

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "Rick Otten" <rotten(at)windfish(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14287: psql_history gets wiped out
Date: 2016-08-12 16:21:13
Message-ID: d3ce9b1d-b5a8-4598-aafa-3f3e1b2a7f22@mm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Rick Otten wrote:

> think I have readline installed on the system:
>
> $ dpkg -l | grep readline
> ii libreadline5:amd64 5.2+dfsg-2 amd64 GNU readline and history
> libraries, run-time libraries
> ii libreadline6:amd64 6.3-4ubuntu2 amd64 GNU readline and history
> libraries, run-time libraries
> ii readline-common

According to the strace output, the replacement of libedit
by libreadline at runtime does not happen in your case
(the "_HiStOrY_V2_" string is from libedit).

This replacement is done by pg_wrapper, a Perl script to which
/usr/bin/psql is normally linked:
$ ls -l /usr/bin/psql
/usr/bin/psql -> ../share/postgresql-common/pg_wrapper
The script pushes libreadline over libedit through LD_PRELOAD, and
launches the actual binary located in
/usr/lib/postgresql/X.Y/bin/psql (where X.Y is the current cluster's
PG version).

You may want to check if that script is not entirely sidestepped in
your setup, as that would explain why libedit gets used. For instance,
a modified PATH or psql being a shell alias could lead to that.

Aside from the bug resulting in an empty file, libedit
will ignore readline's history and remove it from the file
when saving, which is annoying by itself if using it by accident.

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Rick Otten 2016-08-12 16:32:16 Re: BUG #14287: psql_history gets wiped out
Previous Message Tom Lane 2016-08-12 15:30:52 Re: BUG #14287: psql_history gets wiped out