Re: Tab completion for CREATE SCHEMAAUTHORIZATION

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
Cc: Suraj Khamkar <khamkarsuraj(dot)b(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Tab completion for CREATE SCHEMAAUTHORIZATION
Date: 2023-05-09 03:26:16
Message-ID: ZFm9WKBe1czsWOR4@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
v4-0001-Add-tab-completion-for-CREATE-SCHEMA.patch text/x-diff 4.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-05-09 03:32:07 Re: WAL Insertion Lock Improvements
Previous Message Richard Guo 2023-05-09 03:15:42 Re: Improve list manipulation in several places