Return of "can't paste into psql" issue

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Return of "can't paste into psql" issue
Date: 2013-07-17 18:50:10
Message-ID: 51E6E762.6070902@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hackers,

We've seen this before:

http://www.postgresql.org/message-id/b42b73150906271019k6212ba71u6263bc43a8ec8e94@mail.gmail.com

I've run across this again, and am posting it here just in case someone
should be struck by some amazing inspiration on where the problem might
be. Here's the issue:

Pasting text blocks over 100 lines into psql running in
a terminal causes lines to be arbitrarily truncated, mangling
the query or function.

The exact truncation appears random, but is 100% consistent for any
given block of text. For example, one test I ran all lines 101-200
where truncated at character #32, but lines 1-100 were untouched. In
another test, lines #82 and #163 were truncated after the 14th caracter,
but other lines were fine. In the Ubuntu 12.10 tests below, the
truncation occured in the same places regardless of whether I was using
kterm, gterm or xterm.

Here's where I've seen this issue occur:

- Ubuntu 12.10:
- 9.2 installed from source with readline
- 9.4 installed from source with readline, and with libedit
- using Gnome Terminal, Kterm, or xterm
- Ubuntu 12.04:
- 9.2 installed using packages from apt.postgresql.org
- over SSH from a Gnome Terminal
- Mac OSX 10.6
- 9.2 installed from source with readline

Interestingly, here's where it does NOT occur:
- Scientific Linux 6.1
- 9.2 installed from yum.postgresql.org packages
- over SSH from a Gnome Terminal on Ubuntu
- Ubuntu 12.10
- 9.4 from source, compiled --without-readline

Also, the same mangling does not happen with any of the following
applications on Ubuntu 12.10:
- nano
- emacs
- joe
- gedit
- cat, including cat | psql

I could not find another readline-equipped terminal application to test
against.

Ubuntu 12.10 has libreadline 6.2.9, and SciLinux 6.1 has version 6.0.
However, since this happens with libedit as well, I don't think it's
purely a readline issue.

It seems like we're having some kind of bizarre interaction of psql's
readline/libedit hooks and specific terminals or library versions, but
darned if I can even figure out where to look. If anybody has
inspiration strike, please post!

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2013-07-17 18:52:58 Re: Proposal: template-ify (binary) extensions
Previous Message Andrew Dunstan 2013-07-17 18:47:46 Re: Listen/notify across clusters