Skip to content

Commit 0efd878

Browse files
authored
Improve the SQL tab-completion feature for resource group (#1669)
1. For the time being, we will not handle the tab-completion feature of resource queue because there is a trend for resource group to replace resource queue. 2. Correct the description of the gp_resource_manager parameter.
1 parent 880b13e commit 0efd878

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/backend/utils/misc/guc_gp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4936,7 +4936,7 @@ struct config_string ConfigureNamesString_gp[] =
49364936
{
49374937
{"gp_resource_manager", PGC_POSTMASTER, RESOURCES,
49384938
gettext_noop("Sets the type of resource manager."),
4939-
gettext_noop("Only support \"queue\" and \"group\" for now.")
4939+
gettext_noop("Only support \"queue\", \"group\" and \"group-v2\" for now.")
49404940
},
49414941
&gp_resource_manager_str,
49424942
"queue",

src/bin/psql/tab-complete.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,12 @@ psql_completion(const char *text, int start, int end)
16141614
NULL
16151615
};
16161616

1617+
static const char *const list_resource_group_type[] = {
1618+
"CONCURRENCY", "CPU_MAX_PERCENT", "CPUSET", "CPU_WEIGHT",
1619+
"MEMORY_QUOTA", "MIN_COST", "IO_LIMIT",
1620+
NULL
1621+
};
1622+
16171623
/*
16181624
* Temporary workaround for a bug in recent (2019) libedit: it incorrectly
16191625
* de-escapes the input "text", causing us to fail to recognize backslash
@@ -3115,8 +3121,8 @@ psql_completion(const char *text, int start, int end)
31153121
else if (Matches("CREATE", "ROLE|USER|GROUP", MatchAny, "IN"))
31163122
COMPLETE_WITH("GROUP", "ROLE");
31173123

3118-
/* CREATE/DROP RESOURCE GROUP/QUEUE */
3119-
else if (Matches("CREATE|DROP", "RESOURCE"))
3124+
/* CREATE/DROP/ALTER RESOURCE GROUP/QUEUE */
3125+
else if (Matches("CREATE|DROP|ALTER", "RESOURCE"))
31203126
{
31213127
static const char *const list_CREATERESOURCEGROUP[] =
31223128
{"GROUP", "QUEUE", NULL};
@@ -3130,19 +3136,19 @@ psql_completion(const char *text, int start, int end)
31303136
else if (Matches("CREATE", "PROFILE", MatchAny, "LIMIT"))
31313137
COMPLETE_WITH("FAILED_LOGIN_ATTEMPTS", "PASSWORD_REUSE_MAX", "PASSWORD_LOCK_TIME");
31323138

3133-
/* CREATE/DROP RESOURCE GROUP */
3134-
else if (TailMatches("CREATE|DROP", "RESOURCE", "GROUP"))
3139+
/* CREATE/DROP/ALTER RESOURCE GROUP */
3140+
else if (TailMatches("CREATE|DROP|ALTER", "RESOURCE", "GROUP"))
31353141
COMPLETE_WITH_QUERY(Query_for_list_of_resgroups);
31363142
/* CREATE RESOURCE GROUP <name> */
31373143
else if (TailMatches("CREATE|DROP", "RESOURCE", "GROUP", MatchAny))
31383144
COMPLETE_WITH("WITH (");
3145+
/* ALTER RESOURCE GROUP <name> */
3146+
else if (TailMatches("ALTER", "RESOURCE", "GROUP", MatchAny))
3147+
COMPLETE_WITH("SET");
3148+
else if (TailMatches("ALTER", "RESOURCE", "GROUP", MatchAny, "SET"))
3149+
COMPLETE_WITH_LIST(list_resource_group_type);
31393150
else if (TailMatches("RESOURCE", "GROUP", MatchAny, "WITH", "("))
3140-
{
3141-
static const char *const list_CREATERESOURCEGROUP[] =
3142-
{"CONCURRENCY", "CPU_MAX_PERCENT", "CPUSET", "CPU_WEIGHT", "MEMORY_QUOTA", "MIN_COST", "IO_LIMIT", NULL};
3143-
3144-
COMPLETE_WITH_LIST(list_CREATERESOURCEGROUP);
3145-
}
3151+
COMPLETE_WITH_LIST(list_resource_group_type);
31463152

31473153
/* CREATE TYPE */
31483154
else if (Matches("CREATE", "TYPE", MatchAny))

0 commit comments

Comments
 (0)