Re: Patch for psql History Display on MacOSX

From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Stepan Rutz <stepan(dot)rutz(at)gmx(dot)de>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch for psql History Display on MacOSX
Date: 2014-09-05 07:09:54
Message-ID: 20140905070954.GB1012948@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 04, 2014 at 07:51:03AM -0700, Tom Lane wrote:
> Noah Misch <noah(at)leadboat(dot)com> writes:
> > I tried your patches against libedit-28. Wherever a command contains a
> > newline, unpatched psql writes the three bytes "\^A" to the history file, and
> > patched psql writes the four bytes "\012". Unpatched psql correctly reads
> > either form of the history file. Patched psql misinterprets a history file
> > created by unpatched psql, placing 0x01 bytes in the recalled command where it
> > should have newlines. That's a worrisome compatibility break.
>
> I think you got the test cases backwards, or maybe neglected the aspect
> about how unpatched psql will only translate ^J to ^A in the oldest
> (or maybe the newest? too pressed for time to recheck right now) history
> entry.

I, too, had more-productive uses for this time, but morbid curiosity
prevailed. It was the latter: I was testing a one-command history file.
Under libedit-28, unpatched psql writes "^A" for newlines in the oldest
command and "\012" for newlines in subsequent commands. Patched psql writes
"\012" for newlines in the oldest command and "^A" for newlines in subsequent
commands. (Surely a comment is in order if that's intentional. Wasn't the
point to discontinue making the oldest command a special case?) Here's the
matrix of behaviors when recalling history under libedit-28:

master using master-written history:
oldest command: ok
rest: ok
patched using master-written history:
oldest command: broken if it contained a newline
rest: ok
master using patched-written history
oldest command: ok
rest: each broken if it contained a newline
patched using patched-written history
oldest command: ok
rest: ok

Corrupting just the oldest history entry, only when it happens to contain a
newline, is acceptable. If one assumes that users who deploy multiple major
releases use a consistent vintage of minor release, the compatibility problems
after back-patching this change are negligible. That assumption has moderate
credibility.

> We do not escape a problem by refusing to fix it.

I have not recommended a general refusal of fixes for this bug.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Tiikkaja 2014-09-05 07:52:04 Re: proposal: plpgsql - Assert statement
Previous Message Craig Ringer 2014-09-05 07:04:34 Re: Allowing implicit 'text' -> xml|json|jsonb (was: PL/pgSQL 2)