Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpDZl-0007Sx-Gc for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Jan 2019 14:44:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gpDZj-0002US-TU for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Jan 2019 14:44:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpDZj-0002UD-N7 for pgsql-bugs@lists.postgresql.org; Thu, 31 Jan 2019 14:44:19 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpDZh-0000yA-7Y for pgsql-bugs@postgresql.org; Thu, 31 Jan 2019 14:44:19 +0000 Received: from bruce by momjian.us with local (Exim 4.84_2) (envelope-from ) id 1gpDZa-0006tn-SO; Thu, 31 Jan 2019 09:44:10 -0500 Date: Thu, 31 Jan 2019 09:44:10 -0500 From: Bruce Momjian To: =?utf-8?B?0JTQuNC70Y/QvSDQn9Cw0LvQsNGD0LfQvtCy?= Cc: Andrew Gierth , Peter Eisentraut , Alvaro Herrera , Tom Lane , pgsql-bugs@postgresql.org Subject: Re: psql and readline comments Message-ID: <20190131144410.GE22941@momjian.us> References: <201901141559.ne4yhv2nwsl5@alvherre.pgsql> <82eab8ea-5d9d-efab-dcc8-d7713d2b0645@2ndquadrant.com> <20190126001801.GL13803@momjian.us> <87womsjbpq.fsf@news-spur.riddles.org.uk> <20190128191731.GC26761@momjian.us> <87bm40hyg1.fsf@news-spur.riddles.org.uk> <20190129230214.GD25187@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 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 +