Re: CREATE tab completion - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: CREATE tab completion
Date
Msg-id YZYMFdsGH7DDJQSp@paquier.xyz
Whole thread Raw
In response to Re: CREATE tab completion  (Ken Kato <katouknl@oss.nttdata.com>)
Responses Re: CREATE tab completion
List pgsql-hackers
On Thu, Nov 18, 2021 at 04:25:30PM +0900, Ken Kato wrote:
> For this part, I did the following:
> +    else if (TailMatches("CREATE", "SEQUENCE", MatchAny, "AS") ||
> +             TailMatches("CREATE", "TEMP|TEMPORARY", "SEQUENCE", MatchAny, "AS"))
> +        COMPLETE_WITH("smallint", "integer", "bigint");
>
> Am I doing this right? or Are there better ways to do it?

That looks fine per se.

> +/* CREATE SCHEMA */
> +    else if (Matches("CREATE", "SCHEMA"))
> +        COMPLETE_WITH("AUTHORIZATION");
> +    else if (Matches("CREATE", "SCHEMA") && TailMatches("AUTHORIZATION"))
> +        COMPLETE_WITH_QUERY(Query_for_list_of_roles);

The part about CREATE SCHEMA was itching me a bit, until I recalled
this recent thread which has a more complete logic:
https://www.postgresql.org/message-id/87im0efqhp.fsf@wibble.ilmari.org

The rest looks good, I'll take care of that in a bit.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: pg_waldump stucks with options --follow or -f and --stats or -z
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: CREATE tab completion