RE: Support tab completion for upper character inputs in psql

From: "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "smithpb2250(at)gmail(dot)com" <smithpb2250(at)gmail(dot)com>, "peter(dot)eisentraut(at)enterprisedb(dot)com" <peter(dot)eisentraut(at)enterprisedb(dot)com>, "david(dot)zhang(at)highgo(dot)ca" <david(dot)zhang(at)highgo(dot)ca>, "tgl(at)sss(dot)pgh(dot)pa(dot)us" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "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: 2021-04-26 13:47:13
Message-ID: OS0PR01MB6113CA04E06D5BF221BC4FE2FB429@OS0PR01MB6113.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

I've updated the patch to V7 based on the following comments.

On Friday, April 23, 2021 11:58 AM, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> wrote
>All usages of pg_string_tolower don't need a copy.
>So don't we change the function to in-place converter?

Refer to your later discussion with Tom. Keep the code as it is.

> if (completion_info_charp)
>+ {
> e_info_charp = escape_string(completion_info_charp);
>+ if(e_info_charp[0] == '"')
>+ completion_case_sensitive = true;
>+ else
>+ {
>+ le_str = pg_string_tolower(e_info_charp);
>
>It seems right to lower completion_info_charp and ..2 but it is not
>right that change completion_case_sensitive here, which only affects
>the returned candidates.

Agreed, code " completion_case_sensitive = true;" removed.

>By the way COMP_KEYWORD_CASE suggests that *keywords* are completed
>following the setting. However, they are not keywords, but
>identifiers. And some people (including me) might dislike that
>keywords and identifiers follow the same setting. Specifically I
>sometimes want keywords to be upper-cased but identifiers (always) be
>lower-cased.

Changed my design based on your suggestion. Now the upper character inputs for identifiers will always turn to lower case(regardless COMP_KEYWORD_CASE) which I think can be accepted by most of PG users.
Eg: SET BYT<tab> / SET Byt<tab>
output when apply V6 patch: SET BYTEA_OUTPUT
output when apply V7 patch: SET bytea_output

On Friday, April 23, 2021 12:26 PM, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> wrote
>Oh, I accidentally found a doubious behsbior.
>
>=# alter table public.<tab>
>public.c1 public.d1 public."t" public.t public."tt"
>
>The "t" and "tt" are needlessly lower-cased.

Good catch. I didn’t think of schema stuff before.
Bug fixed. Add tap tests for this scenario.

Please let me know if you find more insufficient issue in the patch. Any further suggestion is very welcome.

Regards,
Tang

Attachment Content-Type Size
V7-0001-Support-tab-completion-with-a-query-result-for-upper.patch application/octet-stream 7.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message tanghy.fnst@fujitsu.com 2021-04-26 13:48:55 RE: use pg_strncasecmp to replace strncmp when compare "pg_"
Previous Message Bharath Rupireddy 2021-04-26 13:45:10 Re: Enhanced error message to include hint messages for redundant options error