Re: Fix tab completion after EXCEPT (...) in IMPORT FOREIGN SCHEMA - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Fix tab completion after EXCEPT (...) in IMPORT FOREIGN SCHEMA
Date
Msg-id CAHGQGwGeg-JaD2s6TW7VpNJC_GyJRZ-cOkrp8uwnjN+=4mf=xw@mail.gmail.com
Whole thread
In response to Re: Fix tab completion after EXCEPT (...) in IMPORT FOREIGN SCHEMA  (shveta malik <shveta.malik@gmail.com>)
Responses Re: Fix tab completion after EXCEPT (...) in IMPORT FOREIGN SCHEMA
List pgsql-hackers
On Thu, Apr 16, 2026 at 1:00 PM shveta malik <shveta.malik@gmail.com> wrote:
>
> On Wed, Apr 15, 2026 at 8:45 PM vignesh C <vignesh21@gmail.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");
-------------------

Regards,

--
Fujii Masao



pgsql-hackers by date:

Previous
From: "Zhijie Hou (Fujitsu)"
Date:
Subject: RE: Parallel Apply
Next
From: SATYANARAYANA NARLAPURAM
Date:
Subject: COPY FROM ON_ERROR SET_NULL bypasses domain NOT NULL with partial column list