Re: Tab completion for CREATE SCHEMAAUTHORIZATION
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Cc: Suraj Khamkar <khamkarsuraj.b@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2023-05-09T03:26:16Z
Lists: pgsql-hackers
Attachments
- v4-0001-Add-tab-completion-for-CREATE-SCHEMA.patch (text/x-diff) patch v4-0001
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
Commits
-
Add tab completion for CREATE SCHEMA in psql
- c951e9042dd1 17.0 landed
-
psql: improve tab-complete's handling of variant SQL names.
- 02b8048ba5dc 15.0 cited