Commit 5bc09a74 authored by Thomas Munro's avatar Thomas Munro

Tab-complete CREATE COLLATION.

Reviewed-by: default avatarMichael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/20210117215940.GE8560%40telsasoft.com
parent beb4480c
...@@ -609,6 +609,14 @@ static const SchemaQuery Query_for_list_of_statistics = { ...@@ -609,6 +609,14 @@ static const SchemaQuery Query_for_list_of_statistics = {
.result = "pg_catalog.quote_ident(s.stxname)", .result = "pg_catalog.quote_ident(s.stxname)",
}; };
static const SchemaQuery Query_for_list_of_collations = {
.catname = "pg_catalog.pg_collation c",
.selcondition = "c.collencoding IN (-1, pg_catalog.pg_char_to_encoding(pg_catalog.getdatabaseencoding()))",
.viscondition = "pg_catalog.pg_collation_is_visible(c.oid)",
.namespace = "c.collnamespace",
.result = "pg_catalog.quote_ident(c.collname)",
};
/* /*
* Queries to get lists of names of various kinds of things, possibly * Queries to get lists of names of various kinds of things, possibly
...@@ -1031,7 +1039,7 @@ static const pgsql_thing_t words_after_create[] = { ...@@ -1031,7 +1039,7 @@ static const pgsql_thing_t words_after_create[] = {
{"AGGREGATE", NULL, NULL, Query_for_list_of_aggregates}, {"AGGREGATE", NULL, NULL, Query_for_list_of_aggregates},
{"CAST", NULL, NULL, NULL}, /* Casts have complex structures for names, so {"CAST", NULL, NULL, NULL}, /* Casts have complex structures for names, so
* skip it */ * skip it */
{"COLLATION", "SELECT pg_catalog.quote_ident(collname) FROM pg_catalog.pg_collation WHERE collencoding IN (-1, pg_catalog.pg_char_to_encoding(pg_catalog.getdatabaseencoding())) AND substring(pg_catalog.quote_ident(collname),1,%d)='%s'"}, {"COLLATION", NULL, NULL, &Query_for_list_of_collations},
/* /*
* CREATE CONSTRAINT TRIGGER is not supported here because it is designed * CREATE CONSTRAINT TRIGGER is not supported here because it is designed
...@@ -2433,6 +2441,22 @@ psql_completion(const char *text, int start, int end) ...@@ -2433,6 +2441,22 @@ psql_completion(const char *text, int start, int end)
else if (Matches("CREATE", "ACCESS", "METHOD", MatchAny, "TYPE", MatchAny)) else if (Matches("CREATE", "ACCESS", "METHOD", MatchAny, "TYPE", MatchAny))
COMPLETE_WITH("HANDLER"); COMPLETE_WITH("HANDLER");
/* CREATE COLLATION */
else if (Matches("CREATE", "COLLATION", MatchAny))
COMPLETE_WITH("(", "FROM");
else if (Matches("CREATE", "COLLATION", MatchAny, "FROM"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_collations, NULL);
else if (HeadMatches("CREATE", "COLLATION", MatchAny, "(*"))
{
if (TailMatches("(|*,"))
COMPLETE_WITH("LOCALE =", "LC_COLLATE =", "LC_CTYPE =",
"PROVIDER =", "DETERMINISTIC =");
else if (TailMatches("PROVIDER", "="))
COMPLETE_WITH("libc", "icu");
else if (TailMatches("DETERMINISTIC", "="))
COMPLETE_WITH("true", "false");
}
/* CREATE DATABASE */ /* CREATE DATABASE */
else if (Matches("CREATE", "DATABASE", MatchAny)) else if (Matches("CREATE", "DATABASE", MatchAny))
COMPLETE_WITH("OWNER", "TEMPLATE", "ENCODING", "TABLESPACE", COMPLETE_WITH("OWNER", "TEMPLATE", "ENCODING", "TABLESPACE",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment