From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Improve psql's tab completion for filenames. |
Date: | 2020-01-23 16:07:22 |
Message-ID: | E1iuf0s-0001Z5-06@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Improve psql's tab completion for filenames.
The Readline library contains a fair amount of knowledge about how to
tab-complete filenames, but it turns out that that doesn't work too well
unless we follow its expectation that we use its filename quoting hooks
to quote and de-quote filenames. We were trying to do such quote handling
within complete_from_files(), and that's still what we have to do if we're
using libedit, which lacks those hooks. But for Readline, it works a lot
better if we tell Readline that single-quote is a quoting character and
then provide hooks that know the details of the quoting rules for SQL
and psql meta-commands.
Hence, resurrect the quoting hook functions that existed in the original
version of tab-complete.c (and were disabled by commit f6689a328 because
they "didn't work so well yet"), and whack on them until they do seem to
work well.
Notably, this fixes bug #16059 from Steven Winfield, who pointed out
that the previous coding would strip quote marks from filenames in SQL
COPY commands, even though they're syntactically necessary there.
Now, we not only don't do that, but we'll add a quote mark when you
tab-complete, even if you didn't type one.
Getting this to work across a range of libedit versions (and, to a
lesser extent, libreadline versions) was depressingly difficult.
It will be interesting to see whether the new regression test cases
pass everywhere in the buildfarm.
Some future patch might try to handle quoted SQL identifiers with
similar explicit quoting/dequoting logic, but that's for another day.
Patch by me, reviewed by Peter Eisentraut.
Discussion: https://postgr.es/m/16059-8836946734c02b84@postgresql.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/cd69ec66c88633c09bc9a984a7f0930e09c7c96e
Modified Files
--------------
config/programs.m4 | 52 ++++++-
configure | 87 +++++++++++-
configure.in | 2 +-
src/bin/psql/stringutils.c | 6 +-
src/bin/psql/stringutils.h | 3 +-
src/bin/psql/t/010_tab_completion.pl | 74 ++++++++++
src/bin/psql/tab-complete.c | 259 +++++++++++++++++++++++++++++------
src/include/pg_config.h.in | 8 ++
src/tools/msvc/Solution.pm | 2 +
9 files changed, 438 insertions(+), 55 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-01-23 18:42:34 | pgsql: Clean up formatting.c's logic for matching constant strings. |
Previous Message | Michael Paquier | 2020-01-23 08:06:00 | pgsql: Doc: Fix and tweak documentation for ANALYZE reporting |