PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16059
PG Version11.5
OSLinux
Opened2019-10-15 13:11:29+00
Reported bySteven Winfield
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16059
Logged by:          Steven Winfield
Email address:      (redacted)
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

Messages

DateAuthorSubject
2019-10-15 13:11:29+00PG Bug reporting formBUG #16059: Tab-completion of filenames in COPY commands removes required quotes
2019-10-15 13:38:15+00Francisco OlarteRe: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
2019-10-15 13:52:52+00Steven WinfieldRE: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
2019-11-02 21:14:20+00Tom LaneRe: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
2019-11-02 22:00:30+00Steven WinfieldRE: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes