Re: Tab completion for CREATE SCHEMAAUTHORIZATION

From: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
To: Michael Paquier <michael(at)paquier(dot)xyz>
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-08 16:36:27
Message-ID: 87ttwmu6es.fsf@wibble.ilmari.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Michael Paquier <michael(at)paquier(dot)xyz> writes:

> On Tue, May 02, 2023 at 01:19:49PM +0100, Dagfinn Ilmari Mannsåker wrote:
>> Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org> writes:
>>> This is for completing the word CREATE itself after CREATE SCHEMA
>>> [[<name>] AUTHORIZATION] <name>. The things that can come after that
>>> are already handled generically earlier in the function:
>>>
>>> /* CREATE */
>>> /* complete with something you can create */
>>> else if (TailMatches("CREATE"))
>>> matches = rl_completion_matches(text, create_command_generator);
>>>
>>> create_command_generator uses the words_after_create array, which lists
>>> all the things that can be created.
>
> You are right. I have completely forgotten that this code path would
> append everything that supports CREATE for a CREATE SCHEMA command :)
>
>> But, looking closer at the docs, only tables, views, indexes, sequences
>> and triggers can be created as part of a CREATE SCHEMA statement. Maybe
>> we should add a HeadMatches("CREATE", "SCHEMA") exception in the above?
>
> Yes, it looks like we are going to need an exception and append only
> the keywords that are supported, or we will end up recommending mostly
> things that are not accepted by the parser.

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).

- ilmari

Attachment Content-Type Size
v3-0001-Add-tab-completion-for-CREATE-SCHEMA.patch text/x-diff 4.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2023-05-08 17:25:58 Re: Improve list manipulation in several places
Previous Message Peter Eisentraut 2023-05-08 16:24:31 Re: Proposal for Prototype Implementation to Enhance C/C++ Interoperability in PostgreSQL