Re: Patch for psql History Display on MacOSX

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stepan Rutz <stepan(dot)rutz(at)gmx(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch for psql History Display on MacOSX
Date: 2014-09-01 20:27:57
Message-ID: 17129.1409603277@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Stepan Rutz <stepan(dot)rutz(at)gmx(dot)de> writes:
>> Anyway, I am sure the iteration used in encode_history and decode_history in input.c does not work on libedit.

> Yeah, I noticed your comment about that. That seems odd; a look at the
> Apple libedit sources suggests it should work. I was just about to trace
> through the logic and try to see what's happening.

Sigh ... the answer is that libedit has the direction of traversal
backwards compared to libreadline. If you replace next_history() by
previous_history() in those loops, then it works as expected.

> The reason nobody noticed is possibly that libedit doesn't actually need
> the newline-encoding hack.

Indeed, that's the reason.

> However, we should probably fix the loops if
> they aren't working as expected on libedit, just in case somebody tries
> to copy the logic for some other purpose.

We should either do that, or document what's actually going on here.

A disadvantage of fixing this is that psql versions containing the fix
would be incompatible with versions without (since writing out a history
file containing ^A in place of ^J, and not reversing that encoding upon
reload, would lead to messed-up history data). However, I have a feeling
that we'd better proceed with a fix. Sooner or later, somebody is going
to point out to the libedit guys that they've emulated libreadline
incorrectly. If they fix that, we'll have a situation where psql's using
different libedit versions are incompatible, which would be even more of
a mess.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2014-09-01 20:40:11 Re: Re: [BUGS] Re: BUG #9555: pg_dump for tables with inheritance recreates the table with the wrong order of columns
Previous Message Tom Lane 2014-09-01 20:06:58 Re: Re: [BUGS] Re: BUG #9555: pg_dump for tables with inheritance recreates the table with the wrong order of columns