Re: postgres.app OS X psql character encoding (utf-8) problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris Hiestand <chiestand(at)salk(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: postgres.app OS X psql character encoding (utf-8) problem
Date: 2014-01-09 21:09:11
Message-ID: 17842.1389301751@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Chris Hiestand <chiestand(at)salk(dot)edu> writes:
> If I enter a unicode character in the psql cli, such as:
> user=# select '';

> But before hitting enter, use the keyboard "left" button to move the cursor across all the way to the left edge, and then back all the way to the right, the output get distorted and looks like this:
> user=#select '';;

What this sounds like is that the readline or libedit library doesn't
understand multibyte characters properly. psql itself doesn't have
anything to do with the display of un-entered lines, but relies on
one of those libraries to manage input editing.

The default situation on OS X is generally that psql gets linked against
the Apple-supplied libedit, which goes so far as to masquerade as
readline. Check "otool -L /path/to/psql"; if you see a reference to
/usr/lib/libedit.3.dylib, or to /usr/lib/libreadline.dylib
(which is really just a symlink to the former), then that's what you've
got. While I'm generally a fan and user of Apple stuff, their version
of libedit is just abysmal; we've seen random crashes, complete failure
of tab completion, and other bugs in successive OS X releases. I also
find specific references to multibyte input being busted in other
distros' versions of libedit, eg
http://www.postgresql.org/message-id/4D5B2C5A.8090506@catalyst.net.nz
so it may not be all Apple's fault; but they definitely have a track
record of shipping broken versions of libedit.

I'd strongly recommend installing the GNU readline library and rebuilding
psql against that.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2014-01-09 21:14:32 Re: Add custom properties to a column's definition (pg_attribute)
Previous Message Chris Hiestand 2014-01-09 20:55:04 postgres.app OS X psql character encoding (utf-8) problem