Re: Support tab completion for upper character inputs in psql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
Cc: "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Japin Li <japinli(at)hotmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, "smithpb2250(at)gmail(dot)com" <smithpb2250(at)gmail(dot)com>, "david(dot)zhang(at)highgo(dot)ca" <david(dot)zhang(at)highgo(dot)ca>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Support tab completion for upper character inputs in psql
Date: 2022-01-31 01:54:57
Message-ID: 534641.1643594097@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= <ilmari(at)ilmari(dot)org> writes:
> First, as noted in the test, it doesn't preserve the case of the input
> for keywords appended to the query result. This is easily fixed by
> using `pg_strdup_keyword_case()`, per the first attached patch.

I thought about that, and intentionally didn't do it, because it
would also affect the menus produced by tab completion. Currently,
keywords are (usually) visually distinct from non-keywords in those
menus, thanks to being upper-case where the object names usually
aren't:

regression=# create table foo (c1 int, c2 int);
CREATE TABLE
regression=# alter table foo rename c<TAB>
c1 c2 COLUMN CONSTRAINT

With this change, the keywords would be visually indistinguishable
from the object names, which I felt wouldn't be a net improvement.

We could do something hacky like matching case only when there's
no longer any matching object names, but that might be too magic.

> The second might be more of a matter of style or opinion, but I noticed
> a bunch of `if (foo) free(foo);`, which is redundant given that
> `free(NULL)` is a no-op. To simplify the code further, I also made
> `escape_string(NULL)` be a no-op, returning `NULL`.

Yeah. Our fairly longstanding convention is to avoid doing
free(NULL), dating back to when some platforms would crash on it.
I realize that's archaic now, but I'm not inclined to change
it in just some places.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message houzj.fnst@fujitsu.com 2022-01-31 01:57:33 RE: row filtering for logical replication
Previous Message Kyotaro Horiguchi 2022-01-31 01:50:45 Re: Is there a way (except from server logs) to know the kind of on-going/last checkpoint?