mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +03:00
Tab-complete CREATE COLLATION.
Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/20210117215940.GE8560%40telsasoft.com
This commit is contained in:
parent
beb4480c85
commit
5bc09a7471
@ -609,6 +609,14 @@ static const SchemaQuery Query_for_list_of_statistics = {
|
||||
.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
|
||||
@ -1031,7 +1039,7 @@ static const pgsql_thing_t words_after_create[] = {
|
||||
{"AGGREGATE", NULL, NULL, Query_for_list_of_aggregates},
|
||||
{"CAST", NULL, NULL, NULL}, /* Casts have complex structures for names, so
|
||||
* 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
|
||||
@ -2433,6 +2441,22 @@ psql_completion(const char *text, int start, int end)
|
||||
else if (Matches("CREATE", "ACCESS", "METHOD", MatchAny, "TYPE", MatchAny))
|
||||
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 */
|
||||
else if (Matches("CREATE", "DATABASE", MatchAny))
|
||||
COMPLETE_WITH("OWNER", "TEMPLATE", "ENCODING", "TABLESPACE",
|
||||
|
Loading…
x
Reference in New Issue
Block a user