Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gaMVg-000461-PW for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Dec 2018 15:14:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gaMVf-0004qE-Ii for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Dec 2018 15:14:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gaMVf-0004ks-9n for pgsql-hackers@lists.postgresql.org; Fri, 21 Dec 2018 15:14:43 +0000 Received: from ping.uio.no ([2001:700:100:570::196]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gaMVd-0002Jl-8A for pgsql-hackers@postgresql.org; Fri, 21 Dec 2018 15:14:42 +0000 Received: from [2001:700:100:570::211] (helo=dalvik.ping.uio.no ident=Debian-exim) by ping.uio.no with esmtp (Exim 4.72 #1 (Debian)) id 1gaMVY-00034K-LD; Fri, 21 Dec 2018 16:14:38 +0100 Received: from ilmari by dalvik.ping.uio.no with local (Exim 4.84_2) (envelope-from ) id 1gaMVY-000567-EH; Fri, 21 Dec 2018 16:14:36 +0100 From: ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) To: Michael Paquier Cc: pgsql-hackers@postgresql.org Subject: Re: [PATCH] Improve tab completion for CREATE TABLE References: <20181219050530.GC19856@paquier.xyz> Mail-Copies-To: nobody Date: Fri, 21 Dec 2018 15:14:36 +0000 In-Reply-To: ("Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker=22's?= message of "Wed, 19 Dec 2018 23:39:59 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Exiscan-Spam-Score: -3.7 (---) X-Exiscan-Spam-Report: SpamAssassin 3.3.1 (2010-03-16) on pike.ping.uio.no Score Rule * -5.0 PING_UIO_MAIL_IS_INTERNAL Message has never been outside * 129.240.0.0/16 or 193.157.115.0/24 * 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=-=-= Content-Type: text/plain 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 > 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-completion-for-CREATE-TABLE-.-WITH-options.patch From 5f948f2ebff03a89d18ab621bc21d03cfaa07529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= 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 SET|RESET (" block to the top-level, and reuse it after "CREATE TABLE ( ... ) 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 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 --=-=-=--