From: | Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
Cc: | bt22kawamotok <bt22kawamotok(at)oss(dot)nttdata(dot)com>, Shinya Kato <Shinya11(dot)Kato(at)oss(dot)nttdata(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH]Feature improvement for MERGE tab completion |
Date: | 2022-09-21 05:25:08 |
Message-ID: | 5ed05370-d694-1ea3-045f-01dce952b326@oss.nttdata.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2022/09/21 0:51, Alvaro Herrera wrote:
> The rules starting at line 4111 make me a bit nervous, since nowhere
> we're restricting them to operating only on MERGE lines. I don't think
> it's a real problem since USING is not terribly common anyway. Likewise
> for the ones with WHEN [NOT] MATCHED. I kinda wish we had a way to
> search for stuff like "keyword MERGE appears earlier in the command",
> but we don't have that.
Yeah, I was thinking the same when updating the patch.
How about adding something like PartialMatches() that checks whether
the keywords are included in the input string or not? If so, we can restrict
some tab-completion rules to operating only on MERGE, as follows. I attached
the WIP patch (0002 patch) that introduces PartialMatches().
Is this approach over-complicated? Thought?
+ else if (PartialMatches("MERGE", "INTO", MatchAny, "USING") ||
+ PartialMatches("MERGE", "INTO", MatchAny, "AS", MatchAny, "USING") ||
+ PartialMatches("MERGE", "INTO", MatchAny, MatchAny, "USING"))
+ {
+ /* Complete MERGE INTO ... ON with target table attributes */
+ if (TailMatches("INTO", MatchAny, "USING", MatchAny, "ON"))
+ COMPLETE_WITH_ATTR(prev4_wd);
+ else if (TailMatches("INTO", MatchAny, "AS", MatchAny, "USING", MatchAny, "AS", MatchAny, "ON"))
+ COMPLETE_WITH_ATTR(prev8_wd);
+ else if (TailMatches("INTO", MatchAny, MatchAny, "USING", MatchAny, MatchAny, "ON"))
+ COMPLETE_WITH_ATTR(prev6_wd);
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Attachment | Content-Type | Size |
---|---|---|
v9-0001-psql-Improve-tab-completion-for-MERGE.patch | text/plain | 8.0 KB |
v9-0002-psql-Add-PartialMatches-macro-for-better-tab-complet.patch | text/plain | 7.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2022-09-21 05:40:13 | Re: make additional use of optimized linear search routines |
Previous Message | Amit Kapila | 2022-09-21 05:23:45 | Re: Add common function ReplicationOriginName. |