Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1inN99-0001LN-NZ for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jan 2020 13:37:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1inN98-0001MG-9o for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jan 2020 13:37:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1inN97-0001M9-Tp for pgsql-hackers@lists.postgresql.org; Fri, 03 Jan 2020 13:37:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1inN95-0005Pa-Gs for pgsql-hackers@lists.postgresql.org; Fri, 03 Jan 2020 13:37:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 003Dbbv1012700; Fri, 3 Jan 2020 08:37:37 -0500 From: Tom Lane To: Peter Eisentraut cc: pgsql-hackers@lists.postgresql.org, steven.winfield@cantabcapital.com Subject: Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes In-reply-to: <6ccd23e4-ce58-c2b5-39a1-801a9937ae86@2ndquadrant.com> References: <16059-8836946734c02b84@postgresql.org> <30313.1572729260@sss.pgh.pa.us> <1628.1572820800@sss.pgh.pa.us> <6ccd23e4-ce58-c2b5-39a1-801a9937ae86@2ndquadrant.com> Comments: In-reply-to Peter Eisentraut message dated "Fri, 03 Jan 2020 08:54:35 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12698.1578058657.1@sss.pgh.pa.us> Date: Fri, 03 Jan 2020 08:37:37 -0500 Message-ID: <12699.1578058657@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Eisentraut 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 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