Re: [PATCH] Improve tab completion for CREATE TABLE - Mailing list pgsql-hackers
| From | ilmari@ilmari.org (Dagfinn Ilmari Mannsåker) |
|---|---|
| Subject | Re: [PATCH] Improve tab completion for CREATE TABLE |
| Date | |
| Msg-id | d8jr2e9elek.fsf@dalvik.ping.uio.no Whole thread Raw |
| In response to | Re: [PATCH] Improve tab completion for CREATE TABLE (Michael Paquier <michael@paquier.xyz>) |
| Responses |
Re: [PATCH] Improve tab completion for CREATE TABLE
|
| List | pgsql-hackers |
Michael Paquier <michael@paquier.xyz> writes:
> On Fri, Dec 21, 2018 at 03:14:36PM +0000, Dagfinn Ilmari Mannsåker wrote:
>> Here's a patch that does this (and in passing alphabetises the list of
>> options).
>
> Cool, thanks. The position of the option list is fine. However
> list_TABLEOPTIONS is not a name consistent with the surroundings. So
> we could just use table_level_option?
The CREATE and ALTER TABLE documentation calls them storage parameters,
so I've gone for table_storage_parameters in the attached v2 patch.
> Reordering them is a good idea, log_autovacuum_min_duration being the
> bad entry.
toast_tuple_target was also on the wrong side of the toast.* 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
From 59f30579b72106cf14338b890acfd0c6f0b6009a 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 v2] =?UTF-8?q?Add=20completion=20for=20storage=20parameter?=
=?UTF-8?q?s=20after=20CREATE=20TABLE=20=E2=80=A6=20WITH=20=E2=80=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Move the list of parameters from the "ALTER TABLE <foo> SET|RESET ("
block to the top-level, and reuse it after "CREATE TABLE <foo> ( … )
WITH (".
In passing, rename the variable to and alphabetise the list properly.
---
src/bin/psql/tab-complete.c | 76 ++++++++++++++++++-------------------
1 file changed, 38 insertions(+), 38 deletions(-)
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 5ba6ffba8c..b12ffab312 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 table_storage_parameters[] = {
+ "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);
- }
+ COMPLETE_WITH_LIST(table_storage_parameters);
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(table_storage_parameters);
/* 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
pgsql-hackers by date: