Re: Support tab completion for upper character inputs in psql

2022-07-22 Thread Tom Lane
"tanghy.f...@fujitsu.com" writes: > I think 02b8048 forgot to free some used memory. > Attached a tiny patch to fix it. Please have a check. Right you are. Inspired by that, I tried running some tab-completion operations under valgrind, and found another nearby leak in patternToSQLRegex.

RE: Support tab completion for upper character inputs in psql

2022-07-22 Thread tanghy.f...@fujitsu.com
On Monday, January 31, 2022 3:35 AM, Tom Lane wrote: > "tanghy.f...@fujitsu.com" writes: > > Thanks for your V16 patch, I tested it. > > The results LGTM. > > Pushed, thanks for looking. I think 02b8048 forgot to free some used memory. Attached a tiny patch to fix it. Please have a check.

Re: Support tab completion for upper character inputs in psql

2022-02-04 Thread Tom Lane
=?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= writes: > Tom Lane writes: >>> We could do something hacky like matching case only when there's >>> no longer any matching object names, but that might be too magic. >> I experimented with that, and it actually doesn't seem as weird >> as I feared. See

Re: Support tab completion for upper character inputs in psql

2022-02-01 Thread Tom Lane
=?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= writes: > Tom Lane writes: >>> We could do something hacky like matching case only when there's >>> no longer any matching object names, but that might be too magic. >> I experimented with that, and it actually doesn't seem as weird >> as I feared. See

Re: Support tab completion for upper character inputs in psql

2022-02-01 Thread Dagfinn Ilmari Mannsåker
Tom Lane writes: > I wrote: >> =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= 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.

Re: Support tab completion for upper character inputs in psql

2022-01-31 Thread Tom Lane
I wrote: > =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= 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,

Re: Support tab completion for upper character inputs in psql

2022-01-30 Thread Tom Lane
=?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= 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

Re: Support tab completion for upper character inputs in psql

2022-01-30 Thread Dagfinn Ilmari Mannsåker
Tom Lane writes: > "tanghy.f...@fujitsu.com" writes: >> Thanks for your V16 patch, I tested it. >> The results LGTM. > > Pushed, thanks for looking. I wasn't following this thread, but I noticed a few small potential improvements when I saw the commit. First, as noted in the test, it doesn't

Re: Support tab completion for upper character inputs in psql

2022-01-30 Thread Tom Lane
"tanghy.f...@fujitsu.com" writes: > Thanks for your V16 patch, I tested it. > The results LGTM. Pushed, thanks for looking. regards, tom lane

RE: Support tab completion for upper character inputs in psql

2022-01-29 Thread tanghy.f...@fujitsu.com
On Saturday, January 29, 2022 7:17 AM, Tom Lane wrote: > Sigh ... per the cfbot, this was already blindsided by 95787e849. > As I said, I don't want to sit on this for very long. Thanks for your V16 patch, I tested it. The results LGTM. Regards, Tang

RE: Support tab completion for upper character inputs in psql

2022-01-29 Thread tanghy.f...@fujitsu.com
On Saturday, January 29, 2022 1:03 AM, Tom Lane wrote: > "tanghy.f...@fujitsu.com" writes: > > I did some tests on it and here are something cases I feel we need to > > confirm > > whether they are suitable. > > > 1) postgres=# create table atest(id int, "iD" int, "ID" int); > > 2) CREATE

Re: Support tab completion for upper character inputs in psql

2022-01-28 Thread Tom Lane
"tanghy.f...@fujitsu.com" writes: > I did some tests on it and here are something cases I feel we need to confirm > whether they are suitable. > 1) postgres=# create table atest(id int, "iD" int, "ID" int); > 2) CREATE TABLE > 3) postgres=# alter table atest rename i[TAB] > 4) id"iD" > 5)

RE: Support tab completion for upper character inputs in psql

2022-01-27 Thread tanghy.f...@fujitsu.com
On Friday, January 28, 2022 5:24 AM, Tom Lane wrote: > Here's a fleshed-out patch series for this idea. Thanks for you patch. I did some tests on it and here are something cases I feel we need to confirm whether they are suitable. 1) postgres=# create table atest(id int, "iD" int, "ID" int);

RE: Support tab completion for upper character inputs in psql

2022-01-25 Thread tanghy.f...@fujitsu.com
On Tuesday, January 25, 2022 6:44 PM, Julien Rouhaud wrote: > Thanks for updating the patch. When you do so, please check and update the > commitfest entry accordingly to make sure that people knows it's ready for > review. I'm switching the entry to Needs Review. > Thanks for your reminder.

Re: Support tab completion for upper character inputs in psql

2022-01-25 Thread Tom Lane
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

Re: Support tab completion for upper character inputs in psql

2022-01-25 Thread Julien Rouhaud
Hi, On Tue, Jan 25, 2022 at 05:22:32AM +, tanghy.f...@fujitsu.com wrote: > > I tried to add a flag(casesensitive) in the _complete_from_query(). > Now the attached patch passed all the added tap tests. Thanks for updating the patch. When you do so, please check and update the commitfest

RE: Support tab completion for upper character inputs in psql

2022-01-24 Thread tanghy.f...@fujitsu.com
On Monday, January 24, 2022 6:36 PM, Peter Eisentraut wrote: > The way your patch works now is that the case-insensitive behavior you > are implementing only works if the client encoding is a single-byte > encoding. This isn't what downcase_identifier() does; > downcase_identifier() always

Re: Support tab completion for upper character inputs in psql

2022-01-24 Thread Peter Eisentraut
On 20.01.22 08:37, tanghy.f...@fujitsu.com wrote: 1. The downcasing logic in the patch bears very little resemblance to the backend's actual downcasing logic, which can be found in src/backend/parser/scansup.c's downcase_identifier(). Notably, the patch's restriction to only convert all-ASCII

RE: Support tab completion for upper character inputs in psql

2022-01-19 Thread tanghy.f...@fujitsu.com
On Sunday, January 16, 2022 3:51 AM, Tom Lane said: > Peter Eisentraut writes: > > 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 spent some time looking at this

Re: Support tab completion for upper character inputs in psql

2022-01-19 Thread Julien Rouhaud
Hi, On Sat, Jan 15, 2022 at 01:51:26PM -0500, Tom Lane wrote: > > I spent some time looking at this patch. I'm not very happy with it, > for two reasons: > [...] On top of that the patch doesn't apply anymore: http://cfbot.cputube.org/patch_36_2979.log === Applying patches on top of

Re: Support tab completion for upper character inputs in psql

2022-01-15 Thread Tom Lane
Peter Eisentraut writes: > 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 spent some time looking at this patch. I'm not very happy with it, for two reasons: 1. The

Re: Support tab completion for upper character inputs in psql

2022-01-13 Thread Peter Eisentraut
On 07.01.22 06:17, tanghy.f...@fujitsu.com wrote: On Friday, January 7, 2022 1:08 PM, Japin Li 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

RE: Support tab completion for upper character inputs in psql

2022-01-06 Thread tanghy.f...@fujitsu.com
On Friday, January 7, 2022 1:08 PM, Japin Li 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. > +

Re: Support tab completion for upper character inputs in psql

2022-01-06 Thread Japin Li
On Fri, 07 Jan 2022 at 10:12, tanghy.f...@fujitsu.com wrote: > On Thursday, January 6, 2022 11:57 PM, Tom Lane wrote: >> >> Peter Eisentraut writes: >> > So the ordering of the suggested completions is different. I don't know >> > offhand how that ordering is determined. Perhaps it's

RE: Support tab completion for upper character inputs in psql

2022-01-06 Thread tanghy.f...@fujitsu.com
On Thursday, January 6, 2022 11:57 PM, Tom Lane wrote: > > Peter Eisentraut writes: > > So the ordering of the suggested completions is different. I don't know > > offhand how that ordering is determined. Perhaps it's dependent on > > locale, readline version, or operating system. In any

Re: Support tab completion for upper character inputs in psql

2022-01-06 Thread Tom Lane
Peter Eisentraut writes: > So the ordering of the suggested completions is different. I don't know > offhand how that ordering is determined. Perhaps it's dependent on > locale, readline version, or operating system. In any case, we need to > figure this out to make this test stable. I

Re: Support tab completion for upper character inputs in psql

2022-01-05 Thread Peter Eisentraut
On 10.09.21 15:50, tanghy.f...@fujitsu.com wrote: (A test case for the enum case should be doable easily.) Test added. The enum test is failing on *some* platforms: t/010_tab_completion.pl .. 26/? # Failed test 'complete enum values' # at t/010_tab_completion.pl line 211. # Actual output

RE: Support tab completion for upper character inputs in psql

2021-09-10 Thread tanghy.f...@fujitsu.com
On Tuesday, September 7, 2021 5:25 PM, Peter Eisentraut wrote: >The coding of valid_input_text() seems a bit bulky. I think you can do >the same thing using strspn() without a loop. Thanks, modified in V9 patch. >The name is also not great. It's not like other strings are not "valid".

Re: Support tab completion for upper character inputs in psql

2021-09-07 Thread Peter Eisentraut
On 23.06.21 14:43, tanghy.f...@fujitsu.com wrote: I've updated the patch to V8 since Tom, Kyotaro and Laurenz discussed the lower case issue of German/Turkish language at [1]. Differences from V7 are: * Add a function valid_input_text which checks the input text to see if it only contains

RE: Support tab completion for upper character inputs in psql

2021-06-23 Thread tanghy.f...@fujitsu.com
Hi I've updated the patch to V8 since Tom, Kyotaro and Laurenz discussed the lower case issue of German/Turkish language at [1]. Differences from V7 are: * Add a function valid_input_text which checks the input text to see if it only contains alphabet letters, numbers etc. * Delete the flag

RE: Support tab completion for upper character inputs in psql

2021-04-26 Thread tanghy.f...@fujitsu.com
Hi I've updated the patch to V7 based on the following comments. On Friday, April 23, 2021 11:58 AM, Kyotaro Horiguchi 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

Re: Support tab completion for upper character inputs in psql

2021-04-23 Thread Laurenz Albe
On Fri, 2021-04-23 at 14:44 +0900, Kyotaro Horiguchi wrote: > > The two examples I know of offhand are in German (eszett "ß" downcases to > > "ss") and Turkish (dotted "Í" downcases to "i", likewise dotless "I" > > According to Wikipedia, "ss" is equivalent to "ß" and their upper case > letters

Re: Support tab completion for upper character inputs in psql

2021-04-22 Thread Kyotaro Horiguchi
FWIW... At Fri, 23 Apr 2021 00:17:35 -0400, Tom Lane wrote in > Kyotaro Horiguchi writes: > > At Thu, 22 Apr 2021 23:17:19 -0400, Tom Lane wrote in > >> Doesn't seem like a good idea, because that locks us into an assumption > >> that the downcasing conversion doesn't change the string's

Re: Support tab completion for upper character inputs in psql

2021-04-22 Thread Tom Lane
Kyotaro Horiguchi writes: > At Thu, 22 Apr 2021 23:17:19 -0400, Tom Lane wrote in >> Doesn't seem like a good idea, because that locks us into an assumption >> that the downcasing conversion doesn't change the string's physical >> length. There are a lot of counterexamples to that :-(. I'm

Re: Support tab completion for upper character inputs in psql

2021-04-22 Thread Kyotaro Horiguchi
At Thu, 22 Apr 2021 23:17:19 -0400, Tom Lane wrote in > Kyotaro Horiguchi writes: > > All usages of pg_string_tolower don't need a copy. > > So don't we change the function to in-place converter? > > Doesn't seem like a good idea, because that locks us into an assumption > that the downcasing

Re: Support tab completion for upper character inputs in psql

2021-04-22 Thread Kyotaro Horiguchi
At Fri, 23 Apr 2021 11:58:12 +0900 (JST), Kyotaro Horiguchi wrote in > > Any further comment is very welcome. Oh, I accidentally found a doubious behsbior. =# alter table public. public.c1public.d1public."t" public.t public."tt" The "t" and "tt" are needlessly lower-cased. #

Re: Support tab completion for upper character inputs in psql

2021-04-22 Thread Tom Lane
Kyotaro Horiguchi writes: > All usages of pg_string_tolower don't need a copy. > So don't we change the function to in-place converter? Doesn't seem like a good idea, because that locks us into an assumption that the downcasing conversion doesn't change the string's physical length. There are a

Re: Support tab completion for upper character inputs in psql

2021-04-22 Thread Kyotaro Horiguchi
At Thu, 22 Apr 2021 12:43:42 +, "tanghy.f...@fujitsu.com" wrote in > On Wednesday, April 21, 2021 1:24 PM, Peter Smith > Wrot> >4. Memory not freed in multiple places? > oops. Memory free added. All usages of pg_string_tolower don't need a copy. So don't we change the function to

RE: Support tab completion for upper character inputs in psql

2021-04-22 Thread tanghy.f...@fujitsu.com
On Wednesday, April 21, 2021 1:24 PM, Peter Smith Wrote >I tried playing a bit with your psql patch V5 and I did not find any >problems - it seemed to work as advertised. > >Below are a few code review comments. Thanks for you review. I've updated the patch to V6 according to your comments.

Re: Support tab completion for upper character inputs in psql

2021-04-20 Thread Peter Smith
On Wed, Apr 14, 2021 at 11:34 PM tanghy.f...@fujitsu.com wrote: > > On Thursday, April 8, 2021 4:14 PM, Peter Eisentraut > wrote > > >Seeing the tests you provided, it's pretty obvious that the current > >behavior is insufficient. I think we could probably think of a few more > >tests, for

RE: Support tab completion for upper character inputs in psql

2021-04-14 Thread tanghy.f...@fujitsu.com
On Thursday, April 8, 2021 4:14 PM, Peter Eisentraut wrote >Seeing the tests you provided, it's pretty obvious that the current >behavior is insufficient. I think we could probably think of a few more >tests, for example exercising the "If case insensitive matching was >requested initially,

Re: Support tab completion for upper character inputs in psql

2021-04-08 Thread Peter Eisentraut
On 01.04.21 11:40, tanghy.f...@fujitsu.com wrote: On Wednesday, March 31, 2021 4:05 AM, David Zhang wrote 8 postgres=# update tbl SET DATA = 9 10 postgres=# update TBL SET 11 12 postgres=# So, as you can see the difference is between line 8 and 10 in case 2. It looks like the

RE: Support tab completion for upper character inputs in psql

2021-04-01 Thread tanghy.f...@fujitsu.com
On Wednesday, March 31, 2021 4:05 AM, David Zhang wrote > 8 postgres=# update tbl SET DATA = > 9 > 10 postgres=# update TBL SET > 11 > 12 postgres=# > >So, as you can see the difference is between line 8 and 10 in case 2. It >looks like the lowercase can auto complete more than the

Re: Support tab completion for upper character inputs in psql

2021-03-30 Thread David Zhang
Hi Tang, Thanks a lot for the patch. I did a quick test based on the latest patch V3 on latest master branch "commit 4753ef37e0eda4ba0af614022d18fcbc5a946cc9". Case 1: before patch   1 postgres=# set a   2 all  allow_system_table_mods application_name

RE: Support tab completion for upper character inputs in psql

2021-03-22 Thread tanghy.f...@fujitsu.com
On Tuesday, March 16, 2021 5:20 AM, Peter Eisentraut wrote: >The cases that complete with a query >result are not case insensitive right now. This affects things like > >UPDATE T > >as well. I think your first patch was basically right. But we need to >understand that this affects all

Re: Support tab completion for upper character inputs in psql

2021-03-15 Thread Peter Eisentraut
On 09.02.21 15:48, Tang, Haiying wrote: I'm still confused about the APPROPRIATE behavior of tab completion. It seems ALTER table/tablespace SET/RESET is already case-insensitive. For example # alter tablespace dbspace set(e[tab] # alter tablespace dbspace set(effective_io_concurrency # alter

RE: Support tab completion for upper character inputs in psql

2021-02-09 Thread Tang, Haiying
At Sun, 07 Feb 2021 13:55:00 -0500, Tom Lane wrote in > > This looks like you're trying to force case-insensitive behavior > whether that is appropriate or not. Does not sound like a good idea. I'm still confused about the APPROPRIATE behavior of tab completion. It seems ALTER

RE: Support tab completion for upper character inputs in psql

2021-02-08 Thread Tang, Haiying
/RESET commands). Thanks for your update. I applied your patch, it works well for SET/RESET commands. I added the same modification to SHOW command. The new patch(V2) can support tab completion for upper character inputs in psql for SET/RESET/SHOW commands. Regards, Tang V2-0001-Support-tab-compl

Re: Support tab completion for upper character inputs in psql

2021-02-08 Thread Kyotaro Horiguchi
At Sun, 07 Feb 2021 13:55:00 -0500, Tom Lane wrote in > "Tang, Haiying" writes: > > When using psql I found there's no tab completion for upper character > > inputs. It's really inconvenient sometimes so I try to fix this problem in > > the attached patch. > > This looks like you're trying

Re: Support tab completion for upper character inputs in psql

2021-02-07 Thread Tom Lane
"Tang, Haiying" writes: > When using psql I found there's no tab completion for upper character inputs. > It's really inconvenient sometimes so I try to fix this problem in the > attached patch. This looks like you're trying to force case-insensitive behavior whether that is appropriate or

Support tab completion for upper character inputs in psql

2021-02-06 Thread Tang, Haiying
Hi Hackers, When using psql I found there's no tab completion for upper character inputs. It's really inconvenient sometimes so I try to fix this problem in the attached patch. Here is the examples to show what this patch can do. Action: 1. connect the db using psql 2. input SQL command 3.