Re: [PATCH] Improve tab completion for CREATE TABLE

From: ilmari(at)ilmari(dot)org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=)
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Improve tab completion for CREATE TABLE
Date: 2018-12-19 23:22:29
Message-ID: d8jh8f9f6fe.fsf@dalvik.ping.uio.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

> On Fri, Nov 30, 2018 at 03:44:38PM +0000, Dagfinn Ilmari Mannsåker wrote:
>> ilmari(at)ilmari(dot)org (Dagfinn Ilmari Mannsåker) writes:
>>> Please find attached a patch that adds the following tab completions for
>>> CREATE TABLE:
>>
>> Added to the 2019-01 commitfest: https://commitfest.postgresql.org/21/1895/
>
> + else if (TailMatches("CREATE", "TABLE", MatchAny) ||
> + TailMatches("CREATE", "TEMP|TEMPORARY|UNLOGGED", "TABLE", MatchAny))
> + COMPLETE_WITH("(", "PARTITION OF");
>
> This is missing the completion of "OF TYPE" (no need to print the type
> matches).

Good catch. I've added that, and separate completion of composite type
names after it in the attached v2 patch.

> + else if (TailMatches("CREATE", "TABLE", MatchAny, "(*)") ||
> + TailMatches("CREATE", "UNLOGGED", "TABLE", MatchAny, "(*)"))
> + COMPLETE_WITH("INHERITS (", "PARTITION BY", "WITH (", "TABLESPACE")
>
> Temporary tables can be part of a partition tree, with the parent being
> temporary or permanent.

Yes, the next clause completes all the same options as non-temporary
tables, plus "ON COMMIT":

+ else if (TailMatches("CREATE", "TEMP|TEMPORARY", "TABLE", MatchAny, "(*)"))
+ COMPLETE_WITH("INHERITS (", "PARTITION BY", "WITH (", "ON COMMIT", "TABLESPACE");

> + /* Complete ON COMMIT actions for temp tables */
> + else if (TailMatches("ON", "COMMIT"))
> + COMPLETE_WITH("PRESERVE ROWS", "DELETE ROWS", "DROP");
>
> This causes ON COMMIT to show up for permanent and unlogged tables.

No, this is for completing _after_ ON COMMIT, which is only suggested by
the clause for temporary tables above.

- ilmari
--
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
the consequences of." -- Skud's Meta-Law

Attachment Content-Type Size
v2-0001-Tab-complete-more-options-for-CREATE-TABLE.patch text/x-diff 2.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-12-19 23:35:45 Re: Remove Deprecated Exclusive Backup Mode
Previous Message Greg Stark 2018-12-19 23:22:28 A tidbit I spotted while playing in tablecmds.c