Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
Francisco Olarte <folarte@peoplecall.com>
From: Francisco Olarte <folarte@peoplecall.com>
To: PG Bug reporting form <noreply@postgresql.org>
Cc: pgsql-bugs@lists.postgresql.org, steven.winfield@cantabcapital.com
Date: 2019-10-15T13:38:15Z
Lists: pgsql-bugs, pgsql-hackers
Steven: On Tue, Oct 15, 2019 at 3:12 PM PG Bug reporting form <noreply@postgresql.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.
Commits
-
Improve psql's tab completion for filenames.
- cd69ec66c886 13.0 landed
-
Modernize our readline API a tad.
- 5e7bedc5adba 13.0 landed
-
Add tab completion for EXPLAIN (SETTINGS) in psql
- 4b011cad272e 13.0 cited