pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ilmari@ilmari.org
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [PATCH] Improve tab completion for CREATE TABLE
Date: Fri, 21 Dec 2018 15:14:36 +0000
Message-ID: <d8jwoo2ewtf.fsf@dalvik.ping.uio.no> (raw)
In-Reply-To: <d8jd0pxf5m8.fsf@dalvik.ping.uio.no>
References: <d8j1s77kdbb.fsf@dalvik.ping.uio.no>
	<d8j7eguin89.fsf@dalvik.ping.uio.no>
	<20181219050530.GC19856@paquier.xyz>
	<d8jh8f9f6fe.fsf@dalvik.ping.uio.no>
	<d8jd0pxf5m8.fsf@dalvik.ping.uio.no>

I wrote:
> Another omission I just realised of is that it doesn't complete the list
> of table storage options after after "WITH (".  That should be fairly
> easy to add (we already have the list for completing after ALTER TABLE
> <name> SET|RESET), but it's getting late here now.

Here's a patch that does this (and in passing alphabetises the list of
options).

- ilmari
-- 
- Twitter seems more influential [than blogs] in the 'gets reported in
  the mainstream press' sense at least.               - Matt McLeod
- That'd be because the content of a tweet is easier to condense down
  to a mainstream media article.                      - Calle Dybedahl

Attachments:

0001-Add-completion-for-CREATE-TABLE-.-WITH-options.patch (text/x-diff, 4.2K) download From 5f948f2ebff03a89d18ab621bc21d03cfaa07529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org> Date: Fri, 21 Dec 2018 15:03:19 +0000 Subject: [PATCH] Add completion for CREATE TABLE ... WITH options Move the list of options from the "ALTER TABLE <foo> SET|RESET (" block to the top-level, and reuse it after "CREATE TABLE <foo> ( ... ) WITH (". In passing, alphabetise the option list properly. --- src/bin/psql/tab-complete.c | 74 ++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 5ba6ffba8c..074c88378b 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1005,6 +1005,40 @@ static const pgsql_thing_t words_after_create[] = { {NULL} /* end of list */ }; +static const char *const list_TABLEOPTIONS[] = { + "autovacuum_analyze_scale_factor", + "autovacuum_analyze_threshold", + "autovacuum_enabled", + "autovacuum_freeze_max_age", + "autovacuum_freeze_min_age", + "autovacuum_freeze_table_age", + "autovacuum_multixact_freeze_max_age", + "autovacuum_multixact_freeze_min_age", + "autovacuum_multixact_freeze_table_age", + "autovacuum_vacuum_cost_delay", + "autovacuum_vacuum_cost_limit", + "autovacuum_vacuum_scale_factor", + "autovacuum_vacuum_threshold", + "fillfactor", + "log_autovacuum_min_duration", + "parallel_workers", + "toast.autovacuum_enabled", + "toast.autovacuum_freeze_max_age", + "toast.autovacuum_freeze_min_age", + "toast.autovacuum_freeze_table_age", + "toast.autovacuum_multixact_freeze_max_age", + "toast.autovacuum_multixact_freeze_min_age", + "toast.autovacuum_multixact_freeze_table_age", + "toast.autovacuum_vacuum_cost_delay", + "toast.autovacuum_vacuum_cost_limit", + "toast.autovacuum_vacuum_scale_factor", + "toast.autovacuum_vacuum_threshold", + "toast.log_autovacuum_min_duration", + "toast_tuple_target", + "user_catalog_table", + NULL +}; + /* Forward declaration of functions */ static char **psql_completion(const char *text, int start, int end); @@ -1904,44 +1938,7 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("("); /* ALTER TABLE <foo> SET|RESET ( */ else if (Matches("ALTER", "TABLE", MatchAny, "SET|RESET", "(")) - { - static const char *const list_TABLEOPTIONS[] = - { - "autovacuum_analyze_scale_factor", - "autovacuum_analyze_threshold", - "autovacuum_enabled", - "autovacuum_freeze_max_age", - "autovacuum_freeze_min_age", - "autovacuum_freeze_table_age", - "autovacuum_multixact_freeze_max_age", - "autovacuum_multixact_freeze_min_age", - "autovacuum_multixact_freeze_table_age", - "autovacuum_vacuum_cost_delay", - "autovacuum_vacuum_cost_limit", - "autovacuum_vacuum_scale_factor", - "autovacuum_vacuum_threshold", - "fillfactor", - "parallel_workers", - "log_autovacuum_min_duration", - "toast_tuple_target", - "toast.autovacuum_enabled", - "toast.autovacuum_freeze_max_age", - "toast.autovacuum_freeze_min_age", - "toast.autovacuum_freeze_table_age", - "toast.autovacuum_multixact_freeze_max_age", - "toast.autovacuum_multixact_freeze_min_age", - "toast.autovacuum_multixact_freeze_table_age", - "toast.autovacuum_vacuum_cost_delay", - "toast.autovacuum_vacuum_cost_limit", - "toast.autovacuum_vacuum_scale_factor", - "toast.autovacuum_vacuum_threshold", - "toast.log_autovacuum_min_duration", - "user_catalog_table", - NULL - }; - COMPLETE_WITH_LIST(list_TABLEOPTIONS); - } else if (Matches("ALTER", "TABLE", MatchAny, "REPLICA", "IDENTITY", "USING", "INDEX")) { completion_info_charp = prev5_wd; @@ -2439,6 +2436,9 @@ psql_completion(const char *text, int start, int end) else if (TailMatches("CREATE", "TEMP|TEMPORARY", "TABLE", MatchAny, "(*)")) COMPLETE_WITH("INHERITS (", "ON COMMIT", "PARTITION BY", "TABLESPACE", "WITH ("); + else if (TailMatches("CREATE", "TABLE", MatchAny, "(*)", "WITH", "(") || + TailMatches("CREATE", "TEMP|TEMPORARY|UNLOGGED", "TABLE", MatchAny, "(*)", "WITH", "(")) + COMPLETE_WITH_LIST(list_TABLEOPTIONS); /* Complete CREATE TABLE ON COMMIT with actions */ else if (TailMatches("CREATE", "TEMP|TEMPORARY", "TABLE", MatchAny, "(*)", "ON", "COMMIT")) COMPLETE_WITH("DELETE ROWS", "DROP", "PRESERVE ROWS"); -- 2.20.1

view thread (15+ messages)  latest in thread

Message-ID: <d8jwoo2ewtf.fsf@dalvik.ping.uio.no>
Permalink:  ../d8jwoo2ewtf.fsf@dalvik.ping.uio.no/
Also on:    postgresql.org/message-id/d8jwoo2ewtf.fsf@dalvik.ping.uio.no

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: ilmari@ilmari.org, michael@paquier.xyz
  Subject: Re: [PATCH] Improve tab completion for CREATE TABLE
  In-Reply-To: <d8jwoo2ewtf.fsf@dalvik.ping.uio.no>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox