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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(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: 2020-01-03 13:37:37
Message-ID: 12699.1578058657@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
> On 2019-11-03 23:40, Tom Lane wrote:
>> * The patch now always quotes completed filenames, so quote_if_needed()
>> is misnamed and overcomplicated for this use-case. I left the extra
>> generality in place for possible future use. On the other hand, this
>> is the*only* use-case, so you could also argue that we should just
>> simplify the function's API. I have no strong opinion about that.

> I haven't found an explanation in this thread why it does always quote
> now. That seems a bit unusual. Is there a reason for this? Can we do
> without it?

The core problem we're trying to solve is stated in the thread title:
if you do

prompt# copy mytab from 'myfil<TAB>

then (assuming some completion is available) the current code actually
*removes* the quote, which is completely wrong. Even if the user
didn't type a leading quote, it's better to add one, because COPY
won't work otherwise.

It'd be possible, perhaps, to distinguish between this case and the
cases in backslash commands, which are okay with omitted quotes
(for some filenames). I'm not sure that that would be an improvement
though.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Janes 2020-01-03 13:54:23 Re: Indexing on JSONB field not working
Previous Message Peter Eisentraut 2020-01-03 07:54:35 Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-01-03 13:52:57 Re: pgsql: Add basic TAP tests for psql's tab-completion logic.
Previous Message Amit Kapila 2020-01-03 13:33:27 Re: sidewinder has one failure