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

From Tom Lane
Subject Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
Date
Msg-id 12699.1578058657@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #16059: Tab-completion of filenames in COPY commands removesrequired quotes  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Peter Eisentraut <peter.eisentraut@2ndquadrant.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



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: sidewinder has one failure
Next
From: Tom Lane
Date:
Subject: Re: pgsql: Add basic TAP tests for psql's tab-completion logic.