Re: [PATCH]Feature improvement for MERGE tab completion

Fujii Masao <masao.fujii@oss.nttdata.com>

From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: bt22kawamotok <bt22kawamotok@oss.nttdata.com>, Shinya Kato <Shinya11.Kato@oss.nttdata.com>
Cc: pgsql-hackers@postgresql.org
Date: 2022-09-18T05:29:30Z
Lists: pgsql-hackers

Attachments


On 2022/09/16 11:46, bt22kawamotok wrote:
>> Thanks for updating.
>>
>> +        COMPLETE_WITH("UPDATE", "DELETE", "DO NOTHING");
>>
>> "UPDATE" is always followed by "SET",  so why not complement it with
>> "UPDATE SET"?
> 
> Thanks for reviewing.
> That's a good idea!
> I create new patch v7.

Thanks for updating the patch!

I applied the following changes to the patch. Attached is the updated version of the patch.

The tab-completion code for MERGE was added in the middle of that for LOCK TABLE.
This would be an oversight of the commit that originally supported tab-completion
for MERGE. I fixed this issue.

+	else if (TailMatches("MERGE", "INTO", MatchAny, "AS", MatchAny) ||
+			 TailMatches("MERGE", "INTO", MatchAny, MatchAnyExcept("AS")))
  		COMPLETE_WITH("USING");

This can cause to complete "MERGE INTO <table> USING" with "USING" unexpectedly.
I fixed this issue by replacing MatchAnyExcept("AS") with MatchAnyExcept("USING|AS").

I added some comments.

"MERGE" was tab-completed with just after "EXPLAIN" or "EXPLAIN ANALYZE", etc.
Since "INTO" always follows "MERGE", it's better to complete with "MERGE INTO"
there. I replaced "MERGE" with "MERGE INTO" in those tab-completions.

Regards,

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

Commits

  1. Push lpp variable closer to usage in heapgetpage()

  2. psql: Improve tab-completion for MERGE.