psql tab completion versus Debian's libedit

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: pgbf(at)twiska(dot)com
Subject: psql tab completion versus Debian's libedit
Date: 2022-02-01 21:30:11
Message-ID: 960764.1643751011@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2022-02-01 21:50:31 Re: do only critical work during single-user vacuum?
Previous Message Andrew Dunstan 2022-02-01 21:10:13 Re: CREATEROLE and role ownership hierarchies