Re: Tab completion for CREATE SCHEMAAUTHORIZATION

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: Tab completion for CREATE SCHEMAAUTHORIZATION
Дата
Msg-id ZFm9WKBe1czsWOR4@paquier.xyz
обсуждение исходный текст
Ответ на Re: Tab completion for CREATE SCHEMAAUTHORIZATION  (Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>)
Ответы Re: Tab completion for CREATE SCHEMAAUTHORIZATION  (Michael Paquier <michael@paquier.xyz>)
Список 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

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Richard Guo
Дата:
Сообщение: Re: Improve list manipulation in several places
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: WAL Insertion Lock Improvements