Re: psql and readline comments

From: Дилян Палаузов <dpa-postgres(at)aegee(dot)org>
To: Bruce Momjian <bruce(at)momjian(dot)us>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: psql and readline comments
Date: 2019-01-31 11:46:49
Message-ID: bf6b07a996d5eff4fe27ce0cc8fd42ca052f8869.camel@aegee.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

my reading on the correspondence so far is, that:
- https://www.postgresql.org/docs/current/install-requirements.html states, that libedit is compatible to libreadline,
- libreadline exports the symbol rl_variable_value(), while libedit does not
- both libraries export rl_variable_bind()
- for licensing reasons, sometimes psql is configured and built with support for libedit, but at runtime libreadline is
plugged in the dynamic linker

Corollary: libreadline and libedit are not 1:1 interchangable. libreadline is compatible to libedit, but not vise-
versa.

What speaks against updating the documentation, stating that if psql is configured and build against libreadline, at
runtime it cannot use libedit? There’s in anyway no need for such exaggerated cases. And also clarify, whether
building/configuring against libedit but running against libreadline is supported.

Second approach: if psql was build and configured against libedit, then set comment-begin unconditionally (or do not set
it).

Problematic is anyway the case, when psql is build against libreadline, but executed against libedit.

Third approach: call something like:

char*(psql_rl_variable_value)(const char*) = dlsym(RTLD_DEFAULT, "rl_variable_value");
//if psql_rl_variable_value is NULL, then libedit is used at runtime and not libreadline
if (!psql_rl_variable_value || !strcmp("#", psql_rl_variable_value("comment-begin")))
// set comment-begin if libedit is used, or .libinput does not override the default for "comment-begin"
rl_variable_bind("comment-begin", "--");

Regards
Дилян

On Tue, 2019-01-29 at 18:02 -0500, Bruce Momjian wrote:
> On Tue, Jan 29, 2019 at 04:59:40AM +0000, Andrew Gierth wrote:
> > > > > > > "Bruce" == Bruce Momjian <bruce(at)momjian(dot)us> writes:
> >
> > Bruce> Uh, bind as a key? Does the patch have any effect then?
> >
> > As I said, libedit does not bind M-# by default, and has no equivalent
> > to readline's comment-begin variable. I have no idea what the patch
> > would do when linked against libedit without actually trying it out
> > (which I have not done).
> >
> > Bruce> If not, maybe we should just do this for libreadline.
> >
> > Bear in mind that for licensing reasons, some package builds build psql
> > against libedit but then wedge readline in at runtime using LD_PRELOAD.
> > So doing things differently at compile time based on whether it's
> > libedit or readline will not work well with that.
>
> Seems like adding this would be more trouble than it is worth then.
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2019-01-31 12:26:48 Re: BUG #15589: Due to missing wal, restore ends prematurely and opens database for read/write
Previous Message Adrien NAYRAT 2019-01-31 10:28:58 Re: BUG #15614: Query plan: buffer stats from workers in child operations discarded.