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

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: PG Bug reporting form <noreply(at)postgresql(dot)org>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, steven(dot)winfield(at)cantabcapital(dot)com
Subject: Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
Date: 2019-10-15 13:38:15
Message-ID: CA+bJJbwSiwa6eRSZ9s5Avjbza17Fnn1SZMi40+1vyaR+Z_R99Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Steven:

On Tue, Oct 15, 2019 at 3:12 PM PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> 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).

Not saying it's not a bug, but bear in mind psql CAN NOT correctly
complete filenames for SERVER SIDE copy. You may be running in the
same machine, but even with this and using unix domain sockets it's
difficult to know what is at the other end of the socket ( not sure if
you can always know it even if you are root, and you can have things
like psql connecting through unix domain socket to pgbouncer which
forwards to I-do-not-know-where (.com) .

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

They are different beasts, in \copy you are not completing an sql
command to send to the server, you are completing a command to psql (
which it implemts using an sql command plus some magic ).

Francisco Olarte.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Steven Winfield 2019-10-15 13:52:52 RE: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
Previous Message PG Bug reporting form 2019-10-15 13:11:29 BUG #16059: Tab-completion of filenames in COPY commands removes required quotes

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2019-10-15 13:43:25 Re: Questions/Observations related to Gist vacuum
Previous Message PG Bug reporting form 2019-10-15 13:11:29 BUG #16059: Tab-completion of filenames in COPY commands removes required quotes