psql + libedit command history truncation (was: psql history vs. dearmor (pgcrypto))

From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: psql + libedit command history truncation (was: psql history vs. dearmor (pgcrypto))
Date: 2011-11-15 00:04:34
Message-ID: CAK3UJRGJSGOPDkwhkvQfcUnxZEoK5N3sizau0Ls4YwryyOfyJw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 14, 2011 at 1:01 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> It looks like the problem is that the original has a blank line after
> the line that says "Version: GnuPG v2.0.17 (GNU/Linux)", but when you
> recall it from the query buffer, that extra blank line gets elided.
>
> The attached patch fixes it for me.  I'm a little worried it might
> cause a problem in some case I'm not thinking about, but I can't think
> of any such case right this minute.

(FYI, the patch does seem to fix the problem Tomas was complaining about.)

But it reminded me of another issue. With OS X 10.6.8, and otool -L
reporting that psql depends on libedit version 2.11.0, the up-arrow
recall of Tomas' query gets truncated around here:
5I0/NTm+fFkB0McY9E2fAA [rest of the line missing]

i.e. it's keeping roughly 1021 characters. I was about to just chalk
that up to some limit in libedit's readline() implementation, but I
can see in my ~/.psql_history file that the entire query is logged.
Plus \e recalls the full query correctly. And if I up-arrow to recall
the query, then do anything to modify that recalled query (such as
typing a few characters at the end, then moving back or forth through
the history), then subsequent recalls of the query work fine.

So I'm not sure if this is a bug purely in libedit, or if there's
something amiss in psql. I saw a possibly-related complaint about
psql+libedit on Debian[1]. Anyone have a better guess about what's
going on?
Josh

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=603922

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2011-11-15 00:06:10 Re: why do we need two snapshots per query?
Previous Message Josh Kupershmidt 2011-11-14 23:43:03 Re: proposal: psql concise mode