Freitag, 21. Januar 2011

PostgreSQL vs. libreadline on OSX

Today Thom Brown posted a bug report to pgsql-bugs, where he asked for a potential issue with the interactive terminal psql. As the following reply from Tom Lane explained, this is a long standing issue with the libedit package Apple ships with OSX. Yes, libedit, since libreadline under OSX is just a symlink to libedit:

% ls -la /usr/lib/libreadline.dylib
lrwxr-xr-x 1 root wheel 15 15 Sep 2009 /usr/lib/libreadline.dylib@ -> libedit.2.dylib

If you just configure your PostgreSQL build without any special options, the PostgreSQL binaries will be linked against libedit.
There were several discussions about this in the past and this was even reported to Apple. However, since now (i'm on OSX 10.6.6 for example), nothing happened and the shipped libedit is still unusable with psql.

If you really need to build your own PostgreSQL binaries on OSX (for example you want do a review for a patch in the current CommitFest ;)), i always recommend to use MacPorts and their packaging. I use it for nearly two years and it works quite well (well, at least all libraries required by my installation are working). There's a fairly good instruction on how to setup MacPorts on your MacBook. If you have done your package installation, simply point the configure script to the correct location of the libraries and header files:

./configure --with-libraries=/opt/local/lib --with-includes=/opt/local/include ...

/opt/local is the default location for libraries installed from MacPorts. You also might want to specify additional options. At least, --with-includes and --with-libraries are necessary to point your PostgreSQL builds to the correct libraries.


Theory hat gesagt…

I compile with `--with-libedit` on Mac OS X to avoid the issues with readline incompatibilities. Seems to work well.

Thom hat gesagt…

@Theory Do you mean --with-libedit-preferred? Wouldn't that cause exactly the same problem though due to the bug being in libedit? I've just tried it and still get the original error with that option.