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

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: steven(dot)winfield(at)cantabcapital(dot)com
Subject: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
Date: 2019-10-15 13:11:29
Message-ID: 16059-8836946734c02b84@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

The following bug has been logged on the website:

Bug reference: 16059
Logged by: Steven Winfield
Email address: steven(dot)winfield(at)cantabcapital(dot)com
PostgreSQL version: 11.5
Operating system: Linux
Description:

As per the documentation[1], the COPY command requires the output filename
to be single-quoted.

However, when using psql, a partial COPY command such as this...
COPY pg_catalog.pg_class TO '/usr
...will, on hitting TAB, be converted to this...
COPY pg_catalog.pg_class TO /usr/
...requiring the user to move the cursor back to re-insert the single quote
before finishing the command and executing.

The issue seems to be somewhere around here[2], where complete_from_files[3]
is used to suggest replacements - that function strips quotes from the
existing (partial) filename but doesn't put them back unless quote_if_needed
is true (which I guess it isn't, unless there is a space in the filename for
example).

Note that using the \copy command instead works fine, as filenames do not
need to be quoted in that case.

[1] https://www.postgresql.org/docs/11/sql-copy.html
[2]
https://github.com/postgres/postgres/blob/4b011cad272e997935eb8d80ab741a40b395fdf5/src/bin/psql/tab-complete.c#L2234
[3]
https://github.com/postgres/postgres/blob/4b011cad272e997935eb8d80ab741a40b395fdf5/src/bin/psql/tab-complete.c#L4350

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Francisco Olarte 2019-10-15 13:38:15 Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
Previous Message death lock 2019-10-15 12:34:40 Re: BUG #16049: log_line_prefix=%a and log_connections - application_name missing

Browse pgsql-hackers by date

  From Date Subject
Next Message Francisco Olarte 2019-10-15 13:38:15 Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
Previous Message Andrew Gierth 2019-10-15 12:23:43 Re: Fix most -Wundef warnings