Re: [PATCH]Feature improvement for MERGE tab completion - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: [PATCH]Feature improvement for MERGE tab completion
Date
Msg-id 23586a9b-8978-61dc-0531-03acff3a7b90@oss.nttdata.com
Whole thread Raw
In response to Re: [PATCH]Feature improvement for MERGE tab completion  (bt22kawamotok <bt22kawamotok@oss.nttdata.com>)
Responses Re: [PATCH]Feature improvement for MERGE tab completion
List pgsql-hackers

On 2022/09/14 14:08, bt22kawamotok wrote:
>> When I tried to apply this patch, I got the following warning, please fix it.
>> Other than that, I think everything is fine.
>>
>> $ git apply fix_tab_completion_merge_v4.patch
>> fix_tab_completion_merge_v4.patch:38: trailing whitespace.
>>         else if (TailMatches("USING", MatchAny, "ON", MatchAny) ||
>> fix_tab_completion_merge_v4.patch:39: indent with spaces.
>>                  TailMatches("USING", MatchAny, "AS", MatchAny, "ON",
>> MatchAny) ||
>> fix_tab_completion_merge_v4.patch:40: indent with spaces.
>>                  TailMatches("USING", MatchAny, MatchAny, "ON", MatchAny))
>> fix_tab_completion_merge_v4.patch:53: trailing whitespace.
>>         else if (TailMatches("WHEN", "MATCHED") ||
>> warning: 4 lines add whitespace errors.
> 
> Thanks for reviewing.
> 
> I fixed the problem and make patch v5.
> Please check it.

Thanks for updating the patch!

+    else if (TailMatches("MERGE", "INTO", MatchAny, "USING") ||
+             TailMatches("MERGE", "INTO", MatchAny, MatchAny, "USING") ||
+             TailMatches("MERGE", "INTO", MatchAny, "AS", MatchAny, "USING"))
          COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables);

+    else if (TailMatches("MERGE", "INTO", MatchAny, "AS", MatchAny, "USING") ||
+             TailMatches("MERGE", "INTO", MatchAny, MatchAny, "USING"))
          COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables);

The latter seems redundant and can be removed. The former seems to
cover all the cases where the latter covers.


Not only table but also view, foreign table, etc can be specified after
USING in MERGE command. So ISTM that Query_for_list_of_selectables
should be used at the above tab-completion, instead of Query_for_list_of_tables.
Thought?


+    else if (TailMatches("USING", MatchAny, "ON", MatchAny) ||
+             TailMatches("USING", MatchAny, "ON", MatchAny, MatchAnyExcept("When"), MatchAnyExcept("When")) ||
+             TailMatches("USING", MatchAny, "AS", MatchAny, "ON", MatchAny) ||
+             TailMatches("USING", MatchAny, "AS", MatchAny, "ON", MatchAny, MatchAnyExcept("When"),
MatchAnyExcept("When"))||
 
+             TailMatches("USING", MatchAny, MatchAny, "ON", MatchAny) ||
+             TailMatches("USING", MatchAny, MatchAny, "ON", MatchAny, MatchAnyExcept("When"),
MatchAnyExcept("When")))

"When" should be "WHEN"?


Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION



pgsql-hackers by date:

Previous
From: bt22kawamotok
Date:
Subject: Query jumbling for prepare statement
Next
From: Julien Rouhaud
Date:
Subject: Re: Query jumbling for prepare statement