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 1ir6S6-000094-7u for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Jan 2020 20:36:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ir6S3-00061i-M1 for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Jan 2020 20:36:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ir6S3-00061b-Cw for pgsql-hackers@lists.postgresql.org; Mon, 13 Jan 2020 20:36:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ir6S0-0006sn-OO for pgsql-hackers@lists.postgresql.org; Mon, 13 Jan 2020 20:36:42 +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 00DKaYW6028498; Mon, 13 Jan 2020 15:36:35 -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: <1ed54e8f-d84e-bfbe-ffad-890015e12735@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> <12699.1578058657@sss.pgh.pa.us> <32307.1578290788@sss.pgh.pa.us> <1ed54e8f-d84e-bfbe-ffad-890015e12735@2ndquadrant.com> Comments: In-reply-to Peter Eisentraut message dated "Mon, 13 Jan 2020 17:34:37 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28496.1578947794.1@sss.pgh.pa.us> Date: Mon, 13 Jan 2020 15:36:34 -0500 Message-ID: <28497.1578947794@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Eisentraut writes: > The file name completion portion of this patch seems to work quite well now. Thanks for testing! > I have found a weird behavior with identifier quoting, which is not the > subject of this patch, but it appears to be affected by it. > The good thing is that the new code will behave sensibly with > select * from "pg_cl > which the old code didn't offer anything on. Check. > The problem is that if you have > create table "test""1" (a int); > then the new code responds to > select * from "te > by making that > select * from "te" > whereas the old code curiously handled that perfectly. Right. The underlying cause of both these changes seems to be that what readline passes to psql_completion is just the contents of the string, now that we've told it that double-quote is a string quoting character. So that works fine with 'pg_cl' which didn't need quoting anyway. In your second example, because we generate possible matches that are already quoted-if-necessary, we fail to find anything that bare 'te' is a prefix of, where before we were considering '"te' and it worked. I'll think about how to improve this. Given that we're dequoting filenames explicitly anyway, maybe we don't need to tell readline that double-quote is a quoting character. Another idea is that maybe we ought to refactor things so that identifier dequoting and requoting is handled explicitly, similarly to the way filenames work now. That would make the patch a lot bigger though. regards, tom lane