Re: Support tab completion for upper character inputs in psql

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, Japin Li <japinli(at)hotmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-13 11:29:54
Message-ID: c7fb9ad1-0b77-eda5-0055-02ee472e3a4a@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 07.01.22 06:17, tanghy(dot)fnst(at)fujitsu(dot)com wrote:
> On Friday, January 7, 2022 1:08 PM, Japin Li <japinli(at)hotmail(dot)com> wrote:
>> +/*
>> + * pg_string_tolower - Fold a string to lower case if the string is not quoted
>> + * and only contains ASCII characters.
>> + * For German/Turkish etc text, no change will be made.
>> + *
>> + * The returned value has to be freed.
>> + */
>> +static char *
>> +pg_string_tolower_if_ascii(const char *text)
>> +{
>>
>> s/pg_string_tolower/pg_string_tolower_if_ascii/ for comments.
>>
>
> Thanks for your review.
> Comment fixed in the attached V11 patch.

As I just posted over at [0], the tab completion of enum values appears
to be broken at the moment, so I can't really analyze what impact your
patch would have on it. (But it makes me suspicious about the test case
in your patch.) I suspect it would treat enum labels as
case-insensitive, which would be wrong. But we need to fix that issue
first before we can proceed here.

The rest of the patch seems ok in principle, since AFAICT enums are the
only query result in tab-complete.c that are not identifiers and thus
subject to case issues.

I would perhaps move the pg_string_tolower_if_ascii() calls to before
escape_string() in each case. It won't make a difference to the result,
but it seems conceptually better.

[0]:
https://www.postgresql.org/message-id/8ca82d89-ec3d-8b28-8291-500efaf23b25@enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2022-01-13 11:38:24 Re: Isolation levels on primary and standby
Previous Message Peter Eisentraut 2022-01-13 11:23:02 tab completion of enum values is broken