Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers@lists.postgresql.org, steven.winfield@cantabcapital.com
Date: 2020-01-13T20:36:34Z
Lists: pgsql-bugs, pgsql-hackers
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> 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<TAB> > 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<TAB> > 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
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