Re: [PATCH]Feature improvement for MERGE tab completion

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, 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: 2023-01-03 12:30:35
Message-ID: CALDaNm0RS6-_osaojxD3Ks6kS8zg5KzOo3aRV15pOVFMC_tyag@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 21 Sept 2022 at 10:55, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote:
>
>
>
> 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);

The patch does not apply on top of HEAD as in [1], please post a rebased patch:
=== Applying patches on top of PostgreSQL commit ID
e351f85418313e97c203c73181757a007dfda6d0 ===
=== applying patch ./v9-0001-psql-Improve-tab-completion-for-MERGE.patch
patching file src/bin/psql/tab-complete.c
Hunk #1 FAILED at 1669.
Hunk #2 FAILED at 3641.
Hunk #3 FAILED at 3660.
Hunk #4 FAILED at 4065.
4 out of 4 hunks FAILED -- saving rejects to file
src/bin/psql/tab-complete.c.rej

[1] - http://cfbot.cputube.org/patch_41_3890.log

Regards,
Vignesh

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2023-01-03 13:01:59 Re: MultiXact\SLRU buffers configuration
Previous Message vignesh C 2023-01-03 12:27:40 Re: [PATCH] Expand character set for ltree labels