Re: Support tab completion for upper character inputs in psql
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: "tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>,
Japin Li <japinli@hotmail.com>,
Kyotaro Horiguchi <horikyota.ntt@gmail.com>,
Laurenz Albe <laurenz.albe@cybertec.at>,
"smithpb2250@gmail.com" <smithpb2250@gmail.com>,
"david.zhang@highgo.ca" <david.zhang@highgo.ca>,
"pgsql-hackers@lists.postgresql.org"
<pgsql-hackers@lists.postgresql.org>
Date: 2022-01-25T23:11:27Z
Lists: pgsql-hackers
Attachments
- rethink-tab-complete-quote-handling-wip.patch (text/x-diff) patch
I spent some time contemplating my navel about the concerns I raised upthread about double-quoted identifiers. I concluded that the reason things don't work well in that area is that we're trying to get all the work done by applying quote_ident() on the backend side and then ignoring quoting considerations in tab-complete itself. That sort of works, but not terribly well. The currently proposed patch is sticking a toe into the water of dealing with quoting/downcasing in tab-complete, but we need to go a lot further. I propose that we ought to drop the use of quote_ident() in the tab completion queries altogether, instead having the backend return names as-is, and doing all the dequoting and requoting work in tab-complete. Attached is a very-much-WIP patch along these lines. I make no pretense that it's complete; no doubt some of the individual queries are broken or don't return quite the results we want. But it seems to act the way I think it should for relation names. One thing I'm particularly unsure what to do with is the queries for type names, which want to match against the output of format_type, which'll already have applied quote_ident. We can probably hack something up there, but I ran out of time to mess with that for today. Anyway, I wanted to post this just to see what people think of going in this direction. regards, tom lane PS: I omitted the proposed regression test changes here. Many of them are not at all portable --- different versions of readline/libedit will produce different control character sequences for backspacing, for example. I got a lot of failures when I tried to use those tests with this patch; I've not run down which ones are test portability problems, which are due to intentional behavior changes in this patch, and which are due to breakage I've not fixed yet.
Commits
-
Fix minor memory leaks in psql's tab completion.
- 90474c16a7d2 16.0 landed
- 00cf40328a31 15.0 landed
-
Further tweaks for psql's new tab-completion logic.
- f0cd9097cfac 15.0 landed
-
Treat case of tab-completion keywords a bit more carefully.
- 020258fbd30d 15.0 landed
-
psql: improve tab-complete's handling of variant SQL names.
- 02b8048ba5dc 15.0 landed
-
Make PQcancel use the PGconn's tcp_user_timeout and keepalives settings.
- 5987feb70b5b 15.0 cited
-
Use a WaitLatch for vacuum/autovacuum sleeping
- 4753ef37e0ed 14.0 cited