| From: | vignesh C <vignesh21(at)gmail(dot)com> |
|---|---|
| To: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
| Cc: | shveta malik <shveta(dot)malik(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Fix tab completion after EXCEPT (...) in IMPORT FOREIGN SCHEMA |
| Date: | 2026-04-17 04:32:04 |
| Message-ID: | CALDaNm0SWi3z7M0aqYHqBsvcyS4u2U8tUEkEN=5MMhkdGOpRdg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, 16 Apr 2026 at 22:39, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> On Thu, Apr 16, 2026 at 1:00 PM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
> >
> > On Wed, Apr 15, 2026 at 8:45 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
> > >
> > > Hi all,
> > >
> > > While reviewing tab completion behavior, I noticed an issue after
> > > EXCEPT (...) support was added to CREATE PUBLICATION.
> > > Currently, after typing:
> > > IMPORT FOREIGN SCHEMA public EXCEPT (t1)
> > >
> > > psql correctly suggests FROM SERVER. However, the existing completion
> > > rule uses a generic:
> > > TailMatches("EXCEPT", "(*)")
> > >
> > > Previously this was safe because no other command used EXCEPT (...).
> > > Now that CREATE PUBLICATION also supports EXCEPT (...), the same rule
> > > can incorrectly match publication commands and suggest FROM SERVER
> > > there as well.
> > >
> > > The attached patch fixes this by restricting the EXCEPT (...) path to
> > > IMPORT FOREIGN SCHEMA using HeadMatches(), while preserving the
> > > existing LIMIT TO (...) behavior.
>
> Thanks for the patch!
>
> - else if (TailMatches("LIMIT", "TO", "(*)") ||
> + else if (HeadMatches("IMPORT", "FOREIGN", "SCHEMA", MatchAny) &&
> TailMatches("EXCEPT", "(*)"))
> COMPLETE_WITH("FROM SERVER");
> + else if (TailMatches("LIMIT", "TO", "(*)"))
> + COMPLETE_WITH("FROM SERVER");
>
> Do we really need to split this into two conditions? Wouldn't it be simpler
> to keep a single condition?, for example:
>
> -------------------
> else if (TailMatches("LIMIT", "TO", "(*)") ||
> - TailMatches("EXCEPT", "(*)"))
> + Matches("IMPORT", "FOREIGN", "SCHEMA", MatchAny, "EXCEPT", "(*)"))
> COMPLETE_WITH("FROM SERVER");
> -------------------
Yes, this is better. The attached v2 version patch has the changes for the same.
Regards,
Vignesh
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Fix-tab-completion-after-EXCEPT-in-IMPORT-FOREIGN.patch | application/octet-stream | 1.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2026-04-17 05:23:48 | Re: EXCEPT TABLE - Case inconsistency for describe \d and \dRp+ |
| Previous Message | Amit Langote | 2026-04-17 04:22:19 | Re: Reject invalid databases in pg_get_database_ddl() |