Re: Tab completion for CREATE SCHEMAAUTHORIZATION - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Tab completion for CREATE SCHEMAAUTHORIZATION
Date
Msg-id ZFm9WKBe1czsWOR4@paquier.xyz
Whole thread Raw
In response to Re: Tab completion for CREATE SCHEMAAUTHORIZATION  (Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>)
Responses Re: Tab completion for CREATE SCHEMAAUTHORIZATION
List pgsql-hackers
On Mon, May 08, 2023 at 05:36:27PM +0100, Dagfinn Ilmari Mannsåker wrote:
> Here's an updated v3 patch with that.  While adding that, I noticed that
> CREATE UNLOGGED only tab-completes TABLE and MATERIALIZED VIEW, not
> SEQUENCE, so I added that (and removed MATERIALIZED VIEW when part of
> CREATE SCHEMA).

+       /* but not MATVIEW in CREATE SCHEMA */
+       if (HeadMatches("CREATE", "SCHEMA"))
+           COMPLETE_WITH("TABLE", "SEQUENCE");
+       else
+           COMPLETE_WITH("TABLE", "SEQUENCE", "MATERIALIZED VIEW");

This may look strange at first glance, but the grammar is what it
is..  Perhaps matviews could be part of that at some point.  Or not. :)

+       /* only some object types can be created as part of CREATE SCHEMA */
+       if (HeadMatches("CREATE", "SCHEMA"))
+           COMPLETE_WITH("TABLE", "VIEW", "INDEX", "SEQUENCE", "TRIGGER",
+                         /* for INDEX and TABLE/SEQUENCE, respectively */
+                         "UNIQUE", "UNLOGGED");

Not including TEMPORARY is OK here as the grammar does not allow a
directly to create a temporary schema.  The (many) code paths that
have TailMatches() to cope with CREATE SCHEMA would continue the
completion of added, but at least this approach avoids the
recommendation if possible.

That looks pretty much OK to me.  One tiny comment I have is that this
lacks brackets for the inner blocks, so I have added some in the v4
attached.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Richard Guo
Date:
Subject: Re: Improve list manipulation in several places
Next
From: Michael Paquier
Date:
Subject: Re: WAL Insertion Lock Improvements