From: Ken Kato <katouknl@oss.nttdata.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: [PATCH] ALTER tab completion
Date: Fri, 26 Nov 2021 17:00:44 +0900
Message-ID: <dad8911a89a495a1de9025d9451c3495@oss.nttdata.com> (raw)
In-Reply-To: <YaB/yE4NiiCQqQBM@paquier.xyz>
References: <9497ae9ca1b31eb9b1e97aded1c2ab07@oss.nttdata.com>
<YaB/yE4NiiCQqQBM@paquier.xyz>
Hi,
Thank you for the comments!
I made following updates:
>> -ALTER DEFAULT PRIVILEGES: missing FOR USER
>
> FOR ROLE is an equivalent. That does not seem mandatory to me.
I deleted the completion for "FOR USER".
>> -ALTER VIEW: no completion after ALTER COLUMN column_name
> + /* ALTER VIEW xxx ALTER yyy */
> + else if (Matches("ALTER", "VIEW", MatchAny, "ALTER", MatchAny))
> + COMPLETE_WITH("SET DEFAULT", "DROP DEFAULT");
> It may be cleaner to group this one with "ALTER VIEW xxx ALTER yyy"
> two blocks above.
I put them back to back so that it looks cleaner.
>> -ALTER SEQUENCE: missing AS
> + /* ALTER SEQUENCE <name> AS */
> + else if (TailMatches("ALTER", "SEQUENCE", MatchAny, "AS"))
> + COMPLETE_WITH("smallint", "integer", "bigint");
> Re-quoting Horiguchi-san, that should be COMPLETE_WITH_CS() to keep
> these completions in lower case.
That's what it's for.
I used COMPLETE_WITH_CS instead of COMPLETE_WITH.
Best wishes,
--
Ken Kato
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Attachments:alter_tab_completion.patch (text/x-diff, 2.8K) downloaddiff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.cindex fa2e19593c..4cc32ac0ba 100644--- a/src/bin/psql/tab-complete.c+++ b/src/bin/psql/tab-complete.c@@ -1088,7 +1088,7 @@ static const pgsql_thing_t words_after_create[] = {
{"TEMPORARY", NULL, NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE TEMPORARY
* TABLE ... */
{"TEXT SEARCH", NULL, NULL, NULL},
- {"TRANSFORM", NULL, NULL, NULL},+ {"TRANSFORM", NULL, NULL, NULL, THING_NO_ALTER},
{"TRIGGER", "SELECT pg_catalog.quote_ident(tgname) FROM pg_catalog.pg_trigger WHERE substring(pg_catalog.quote_ident(tgname),1,%d)='%s' AND NOT tgisinternal"},
{"TYPE", NULL, NULL, &Query_for_list_of_datatypes},
{"UNIQUE", NULL, NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE UNIQUE
@@ -1754,7 +1754,10 @@ psql_completion(const char *text, int start, int end)
/* ALTER FOREIGN DATA WRAPPER <name> */
else if (Matches("ALTER", "FOREIGN", "DATA", "WRAPPER", MatchAny))
- COMPLETE_WITH("HANDLER", "VALIDATOR", "OPTIONS", "OWNER TO", "RENAME TO");+ COMPLETE_WITH("HANDLER", "VALIDATOR", "NO",+ "OPTIONS", "OWNER TO", "RENAME TO");+ else if (Matches("ALTER", "FOREIGN", "DATA", "WRAPPER", MatchAny, "NO"))+ COMPLETE_WITH("HANDLER", "VALIDATOR");
/* ALTER FOREIGN TABLE <name> */
else if (Matches("ALTER", "FOREIGN", "TABLE", MatchAny))
@@ -1907,9 +1910,12 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH("DEFAULT", "NOT NULL", "SCHEMA");
/* ALTER SEQUENCE <name> */
else if (Matches("ALTER", "SEQUENCE", MatchAny))
- COMPLETE_WITH("INCREMENT", "MINVALUE", "MAXVALUE", "RESTART", "NO",- "CACHE", "CYCLE", "SET SCHEMA", "OWNED BY", "OWNER TO",- "RENAME TO");+ COMPLETE_WITH("AS", "INCREMENT", "MINVALUE", "MAXVALUE", "RESTART",+ "NO", "CACHE", "CYCLE", "SET SCHEMA", "OWNED BY",+ "OWNER TO", "RENAME TO");+ /* ALTER SEQUENCE <name> AS */+ else if (TailMatches("ALTER", "SEQUENCE", MatchAny, "AS"))+ COMPLETE_WITH_CS("smallint", "integer", "bigint");
/* ALTER SEQUENCE <name> NO */
else if (Matches("ALTER", "SEQUENCE", MatchAny, "NO"))
COMPLETE_WITH("MINVALUE", "MAXVALUE", "CYCLE");
@@ -1935,6 +1941,12 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_ATTR(prev2_wd, " UNION SELECT 'COLUMN' UNION SELECT 'TO'");
else if (Matches("ALTER", "VIEW", MatchAny, "ALTER|RENAME", "COLUMN"))
COMPLETE_WITH_ATTR(prev3_wd, "");
+ /* ALTER VIEW xxx ALTER yyy */+ else if (Matches("ALTER", "VIEW", MatchAny, "ALTER", MatchAny))+ COMPLETE_WITH("SET DEFAULT", "DROP DEFAULT");+ /* ALTER VIEW xxx ALTER COLUMN yyy */+ else if (Matches("ALTER", "VIEW", MatchAny, "ALTER", "COLUMN", MatchAny))+ COMPLETE_WITH("SET DEFAULT", "DROP DEFAULT");
/* ALTER VIEW xxx RENAME yyy */
else if (Matches("ALTER", "VIEW", MatchAny, "RENAME", MatchAnyExcept("TO")))
COMPLETE_WITH("TO");
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: katouknl@oss.nttdata.com, michael@paquier.xyz
Subject: Re: [PATCH] ALTER tab completion
In-Reply-To: <dad8911a89a495a1de9025d9451c3495@oss.nttdata.com>
References: <9497ae9ca1b31eb9b1e97aded1c2ab07@oss.nttdata.com> <YaB/yE4NiiCQqQBM@paquier.xyz> <dad8911a89a495a1de9025d9451c3495@oss.nttdata.com>
* 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