Hi hackers,
I noticed that there are some tab completions missing for the following
commands:
-CREATE CONVERSION : missing FOR, TO, FROM
-CREATE DOMAIN : missing after AS
-CREATE LANGUAGE : missing after HANDLER
-CREATE SCHEMA : missing AUTHORIZATION, IF NOT EXISTS
-CREATE SEQUENCE : missing AS
-CREATE TRANSFORM : missing after FOR
I made a patch for this, so please have a look.
Best wishes,
--
Ken Kato
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 4f724e4428..0216b50946 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2572,6 +2572,20 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH("true", "false");
}
+ /* CREATE CONVERSION */
+ else if (Matches("CREATE", "CONVERSION", MatchAny))
+ COMPLETE_WITH("FOR");
+ else if (Matches("CREATE", "CONVERSION", MatchAny, "FOR"))
+ COMPLETE_WITH_QUERY(Query_for_list_of_encodings);
+ else if (Matches("CREATE", "CONVERSION", MatchAny, "FOR", MatchAny))
+ COMPLETE_WITH("TO");
+ else if (Matches("CREATE", "CONVERSION", MatchAny, "FOR", MatchAny, "TO"))
+ COMPLETE_WITH_QUERY(Query_for_list_of_encodings);
+ else if (Matches("CREATE", "CONVERSION", MatchAny, "FOR", MatchAny, "TO", MatchAny))
+ COMPLETE_WITH("FROM");
+ else if (Matches("CREATE", "CONVERSION", MatchAny, "FOR", MatchAny, "TO", MatchAny, "FROM"))
+ COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions, NULL);
+
/* CREATE DATABASE */
else if (Matches("CREATE", "DATABASE", MatchAny))
COMPLETE_WITH("OWNER", "TEMPLATE", "ENCODING", "TABLESPACE",
@@ -2582,6 +2596,17 @@ psql_completion(const char *text, int start, int end)
else if (Matches("CREATE", "DATABASE", MatchAny, "TEMPLATE"))
COMPLETE_WITH_QUERY(Query_for_list_of_template_databases);
+ /* CREATE DOMAIN */
+ else if (Matches("CREATE", "DOMAIN", MatchAny))
+ COMPLETE_WITH("AS");
+ else if (Matches("CREATE", "DOMAIN", MatchAny, "AS"))
+ COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);
+ else if (Matches("CREATE", "DOMAIN", MatchAny, "AS", MatchAny))
+ COMPLETE_WITH("COLLATE", "DEFAULT", "CONSTRAINT",
+ "NOT NULL", "NULL", "CHECK (");
+ else if (Matches("CREATE", "DOMAIN", MatchAny, "COLLATE"))
+ COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_collations, NULL);
+
/* CREATE EXTENSION */
/* Complete with available extensions rather than installed ones. */
else if (Matches("CREATE", "EXTENSION"))
@@ -2661,6 +2686,12 @@ psql_completion(const char *text, int start, int end)
!TailMatches("FOR", MatchAny, MatchAny, MatchAny))
COMPLETE_WITH("(");
+ /* CREATE LANGUAGE */
+ else if (Matches("CREATE", "LANGUAGE", MatchAny))
+ COMPLETE_WITH("HANDLER");
+ else if (Matches("CREATE", "LANGUAGE", MatchAny, "HANDLER", MatchAny))
+ COMPLETE_WITH("INLINE", "VALIDATOR");
+
/* CREATE OR REPLACE */
else if (Matches("CREATE", "OR"))
COMPLETE_WITH("REPLACE");
@@ -2802,11 +2833,23 @@ psql_completion(const char *text, int start, int end)
else if (TailMatches("AS", "ON", "SELECT|UPDATE|INSERT|DELETE", "TO"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
+/* CREATE SCHEMA */
+ else if (Matches("CREATE", "SCHEMA"))
+ COMPLETE_WITH("AUTHORIZATION", "IF NOT EXISTS");
+ else if (Matches("CREATE", "SCHEMA", "IF", "NOT", "EXISTS"))
+ {
+ completion_info_charp = prev2_wd;
+ COMPLETE_WITH_QUERY(Query_for_list_of_schemas
+ " UNION SELECT 'AUTORIZATION'");
+ }
+ else if (Matches("CREATE", "SCHEMA") && TailMatches("AUTHORIZATION"))
+ COMPLETE_WITH_QUERY(Query_for_list_of_roles);
+
/* CREATE SEQUENCE --- is allowed inside CREATE SCHEMA, so use TailMatches */
else if (TailMatches("CREATE", "SEQUENCE", MatchAny) ||
TailMatches("CREATE", "TEMP|TEMPORARY", "SEQUENCE", MatchAny))
- COMPLETE_WITH("INCREMENT BY", "MINVALUE", "MAXVALUE", "NO", "CACHE",
- "CYCLE", "OWNED BY", "START WITH");
+ COMPLETE_WITH("AS", "INCREMENT BY", "MINVALUE", "MAXVALUE", "NO",
+ "CACHE","CYCLE", "OWNED BY", "START WITH");
else if (TailMatches("CREATE", "SEQUENCE", MatchAny, "NO") ||
TailMatches("CREATE", "TEMP|TEMPORARY", "SEQUENCE", MatchAny, "NO"))
COMPLETE_WITH("MINVALUE", "MAXVALUE", "CYCLE");
@@ -2882,6 +2925,19 @@ psql_completion(const char *text, int start, int end)
else if (Matches("CREATE", "TEXT", "SEARCH", "CONFIGURATION|DICTIONARY|PARSER|TEMPLATE", MatchAny))
COMPLETE_WITH("(");
+/* CREATE TRANSFORM */
+ else if (Matches("CREATE", "TRANSFORM"))
+ COMPLETE_WITH("FOR");
+ else if (Matches("CREATE", "TRANSFORM", "FOR"))
+ COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);
+ else if (Matches("CREATE", "TRANSFORM", "FOR", MatchAny)
+ COMPLETE_WITH("LANGUAGE")
+ else if (Matches("CREATE", "TRANSFORM", "FOR", MatchAny, "LANGUAGE")
+ {
+ completion_info_charp = prev2_wd;
+ COMPLETE_WITH_QUERY(Query_for_list_of_languages);
+ }
+
/* CREATE SUBSCRIPTION */
else if (Matches("CREATE", "SUBSCRIPTION", MatchAny))
COMPLETE_WITH("CONNECTION");