pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: bt22kawamotok <bt22kawamotok@oss.nttdata.com>
To: Shinya Kato <Shinya11.Kato@oss.nttdata.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [PATCH]Feature improvement for MERGE tab completion
Date: Mon, 12 Sep 2022 15:53:46 +0900
Message-ID: <c5730fb146c8ded48d537724e1456bfb@oss.nttdata.com> (raw)
In-Reply-To: <359a46c295eae938d84552c11818ab62@oss.nttdata.com>
References: <9f1ad2a87a58cd5e7d64f3993130958d@oss.nttdata.com>
	<359a46c295eae938d84552c11818ab62@oss.nttdata.com>

> 	else if (TailMatches("USING", MatchAny, "ON", MatchAny, "WHEN"))
> 		COMPLETE_WITH("MATCHED", "NOT MATCHED");
> 	else if (TailMatches("USING", MatchAny, "AS", MatchAny, "ON",
> MatchAny, "WHEN"))
> 		COMPLETE_WITH("MATCHED", "NOT MATCHED");
> 	else if (TailMatches("USING", MatchAny, MatchAny, "ON", MatchAny, 
> "WHEN"))
> 		COMPLETE_WITH("MATCHED", "NOT MATCHED");
> 
> I thought it would be better to describe this section as follows,
> summarizing the conditions
> 
> 	else if (TailMatches("USING", MatchAny, "ON", MatchAny, "WHEN") ||
> 			 TailMatches("USING", MatchAny, "AS", MatchAny, "ON", MatchAny, 
> "WHEN") ||
> 			 TailMatches("USING", MatchAny, MatchAny, "ON", MatchAny, "WHEN"))
> 		COMPLETE_WITH("MATCHED", "NOT MATCHED");
> 
> There are similar redundancies in the tab completion of MERGE
> statement, so why not fix that as well?

Thanks for your review.

A new patch has been created to reflect the changes you indicated.
I also found a problem that "DO NOTHING" is not completed when type 
"WHEN MATCHED <tab>", so I fixed it as well.

Regards,

Kotaro Kawamoto

Attachments:

fix_tab_completion_merge_v2.patch (text/x-diff, 1.6K) download diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 62a39779b9..c05b52e49a 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -4068,7 +4068,7 @@ psql_completion(const char *text, int start, int end) /* with [AS] alias */ else if (TailMatches("MERGE", "INTO", MatchAny, "AS", MatchAny)) COMPLETE_WITH("USING"); - else if (TailMatches("MERGE", "INTO", MatchAny, MatchAny)) + else if (TailMatches("MERGE", "INTO", MatchAny, MatchAny) && !TailMatches("AS")) COMPLETE_WITH("USING"); else if (TailMatches("MERGE", "INTO", MatchAny, "AS", MatchAny, "USING")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables); @@ -4095,12 +4095,16 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("WHEN MATCHED", "WHEN NOT MATCHED"); else if (TailMatches("USING", MatchAny, MatchAny, "ON", MatchAny)) COMPLETE_WITH("WHEN MATCHED", "WHEN NOT MATCHED"); + else if (TailMatches("USING", MatchAny, "ON", MatchAny, "WHEN")) || + (TailMatches("USING", MatchAny, "AS", MatchAny, "ON", MatchAny, "WHEN")) || + (TailMatches("USING", MatchAny, MatchAny, "ON", MatchAny, "WHEN")) + COMPLETE_WITH("MATCHED", "NOT MATCHED"); else if (TailMatches("WHEN", "MATCHED")) COMPLETE_WITH("THEN", "AND"); else if (TailMatches("WHEN", "NOT", "MATCHED")) COMPLETE_WITH("THEN", "AND"); else if (TailMatches("WHEN", "MATCHED", "THEN")) - COMPLETE_WITH("UPDATE", "DELETE"); + COMPLETE_WITH("UPDATE", "DELETE", "DO NOTHING"); else if (TailMatches("WHEN", "NOT", "MATCHED", "THEN")) COMPLETE_WITH("INSERT", "DO NOTHING");

view thread (21+ messages)  latest in thread

Message-ID: <c5730fb146c8ded48d537724e1456bfb@oss.nttdata.com>
Permalink:  ../c5730fb146c8ded48d537724e1456bfb@oss.nttdata.com/
Also on:    postgresql.org/message-id/c5730fb146c8ded48d537724e1456bfb@oss.nttdata.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: bt22kawamotok@oss.nttdata.com, Shinya11.Kato@oss.nttdata.com
  Subject: Re: [PATCH]Feature improvement for MERGE tab completion
  In-Reply-To: <c5730fb146c8ded48d537724e1456bfb@oss.nttdata.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox