psql tab completion versus Debian's libedit - Mailing list pgsql-hackers

From Tom Lane
Subject psql tab completion versus Debian's libedit
Date
Msg-id 960764.1643751011@sss.pgh.pa.us
Whole thread Raw
Responses Re: psql tab completion versus Debian's libedit
List pgsql-hackers
I chased down the failure that kittiwake has been showing since
02b8048ba [1].  It's not hard to reproduce if you have an older
Debian release and you build --with-libedit-preferred.
Manual experimentation shows that when these versions of libedit
complete a string containing double quotes, they insist on
backslashing all the double quotes :-(.  That is, if you have
a table "foobar" and you type

select * from "foo<TAB>

what you'll get is

select * from \"foobar\"

Digging into the source code, I find that libedit versions prior
to 3.1-20210522 are unshakably convinced that anything you are
completing should be escaped per shell quoting rules :-(.  AFAICT
there is no way to turn that off without replacing the *entire*
tab completion infrastructure.

3.1-20210522 changed this to the extent of disabling quoting
if the application supplies a rl_attempted_completion_function,
as we do.  (Fine for us, sucks for anybody who did want shell
quoting.)

I'm not too sure about the relationship of Debian's version of
libedit to anyone else's.  Apple's version, for one, lacks this
bug.  But it does appear that you don't want to use libedit on
Debian unless you have a very late-model release.

We can paper over the regression failure by making the test
cases allow backslashes, but I wonder if we need something
in the documentation discouraging people from choosing these
versions of libedit over readline.  They're pretty broken for
completions involving double-quoted names even before 02b8048ba.

            regards, tom lane

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=kittiwake&dt=2022-01-31%2016%3A24%3A48



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: CREATEROLE and role ownership hierarchies
Next
From: John Naylor
Date:
Subject: Re: do only critical work during single-user vacuum?