Re: psql and readline comments - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: psql and readline comments
Date
Msg-id 20190131144410.GE22941@momjian.us
Whole thread Raw
In response to Re: psql and readline comments  (Дилян Палаузов <dpa-postgres@aegee.org>)
List pgsql-bugs
On Thu, Jan 31, 2019 at 11:46:49AM +0000, Дилян Палаузов wrote:
> 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", "--");

Wow, run-time probe for the library --- interesting.  I think a more
simple case would be to just unconditionally set the variable, and if
libedit is being used at run-time, nothing happens, but using
libreadline at run-time would work.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +


pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: BUG #15609: synchronous_commit=off insert performance regressionwith secondary indexes
Next
From: Andrew Gierth
Date:
Subject: Re: psql and readline comments