Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-hackers@lists.postgresql.org, steven.winfield@cantabcapital.com
Date: 2019-12-27T22:36:56Z
Lists: pgsql-bugs, pgsql-hackers

Attachments

Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> One minor thing I noticed is that if I enter
> \copy t from '/tmp/t'<tab>
> and I have files /tmp/t and /tmp/tst then it removes the ending quote.

Yeah, that bothered me too.  [ pokes at it for a bit... ]  The
quote_file_name function isn't passed enough info to handle this
in a clean way, but we can make it work if we don't mind introducing
some more coupling with psql_completion, ie having the latter remember
whether the raw input word ended with a quote.  As per v4.

> (The unpatched version removes *both* quotes.  The quotes there are not
> mandatory, but the new version works better when there are files with
> whitespace in the name.)

Or when you're completing in a COPY rather than \copy --- then, removing
the quotes is broken whether there's whitespace or not.

			regards, tom lane

Commits

  1. Improve psql's tab completion for filenames.

  2. Modernize our readline API a tad.

  3. Add tab completion for EXPLAIN (SETTINGS) in psql