Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infoschema: change schema of information_schema.resource_groups #41158

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions ddl/resource_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestResourceGroupBasic(t *testing.T) {
re.Equal(uint64(2000), g.RURate)
re.Equal(int64(-1), g.BurstLimit)

tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 2000 0 YES"))
tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 2000 YES"))

tk.MustExec("drop resource group x")
g = testResourceGroupNameFromIS(t, tk.Session(), "x")
Expand Down Expand Up @@ -126,25 +126,30 @@ func TestResourceGroupBasic(t *testing.T) {
tk.MustContainErrMsg("create resource group x ru_per_sec=1000 ru_per_sec=200, ru_per_sec=300", "Dupliated options specified")
tk.MustGetErrCode("create resource group x burstable, burstable", mysql.ErrParse)
tk.MustContainErrMsg("create resource group x burstable, burstable", "Dupliated options specified")
tk.MustGetErrCode("create resource group x ru_per_sec=1000, burstable, burstable", mysql.ErrParse)
tk.MustContainErrMsg("create resource group x ru_per_sec=1000, burstable, burstable", "Dupliated options specified")
tk.MustGetErrCode("create resource group x burstable, ru_per_sec=1000, burstable", mysql.ErrParse)
tk.MustContainErrMsg("create resource group x burstable, ru_per_sec=1000, burstable", "Dupliated options specified")
groups, err := infosync.ListResourceGroups(context.TODO())
require.Equal(t, 0, len(groups))
require.NoError(t, err)

// Check information schema table information_schema.resource_groups
tk.MustExec("create resource group x RU_PER_SEC=1000")
tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 1000 0 NO"))

tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 1000 NO"))
tk.MustExec("alter resource group x RU_PER_SEC=2000 BURSTABLE")
tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 2000 0 YES"))
tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 2000 YES"))
tk.MustExec("alter resource group x BURSTABLE RU_PER_SEC=3000")
tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 3000 0 YES"))
tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 3000 YES"))
tk.MustQuery("show create resource group x").Check(testkit.Rows("x CREATE RESOURCE GROUP `x` RU_PER_SEC=3000 BURSTABLE"))

tk.MustExec("create resource group y BURSTABLE RU_PER_SEC=2000")
tk.MustQuery("select * from information_schema.resource_groups where name = 'y'").Check(testkit.Rows("y 2000 0 YES"))
tk.MustQuery("select * from information_schema.resource_groups where name = 'y'").Check(testkit.Rows("y 2000 YES"))
tk.MustQuery("show create resource group y").Check(testkit.Rows("y CREATE RESOURCE GROUP `y` RU_PER_SEC=2000 BURSTABLE"))

tk.MustExec("alter resource group y RU_PER_SEC=4000 BURSTABLE")
tk.MustQuery("select * from information_schema.resource_groups where name = 'y'").Check(testkit.Rows("y 4000 0 YES"))
tk.MustQuery("select * from information_schema.resource_groups where name = 'y'").Check(testkit.Rows("y 4000 YES"))
tk.MustQuery("show create resource group y").Check(testkit.Rows("y CREATE RESOURCE GROUP `y` RU_PER_SEC=4000 BURSTABLE"))

tk.MustQuery("select count(*) from information_schema.resource_groups").Check(testkit.Rows("2"))
Expand Down
2 changes: 0 additions & 2 deletions executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3406,7 +3406,6 @@ func (e *memtableRetriever) setDataFromResourceGroups() error {
row := types.MakeDatums(
group.Name,
group.RUSettings.RU.Settings.FillRate,
uint64(group.RUSettings.RU.Tokens),
burstable,
)
rows = append(rows, row)
Expand All @@ -3416,7 +3415,6 @@ func (e *memtableRetriever) setDataFromResourceGroups() error {
group.Name,
nil,
nil,
nil,
)
rows = append(rows, row)
}
Expand Down
1 change: 0 additions & 1 deletion infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,6 @@ var tableMemoryUsageOpsHistoryCols = []columnInfo{
var tableResourceGroupsCols = []columnInfo{
{name: "NAME", tp: mysql.TypeVarchar, size: resourcegroup.MaxGroupNameLength, flag: mysql.NotNullFlag},
{name: "RU_PER_SEC", tp: mysql.TypeLonglong, size: 21},
{name: "RU_TOKENS", tp: mysql.TypeLonglong, size: 21},
{name: "BURSTABLE", tp: mysql.TypeVarchar, size: 3},
}

Expand Down
10 changes: 6 additions & 4 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -11970,19 +11970,21 @@ yynewstate:
}
case 10:
{
parser.yyVAL.item = append(yyS[yypt-1].item.([]*ast.ResourceGroupOption), yyS[yypt-0].item.(*ast.ResourceGroupOption))
if yyS[yypt-1].item.([]*ast.ResourceGroupOption)[0].Tp == yyS[yypt-0].item.(*ast.ResourceGroupOption).Tp {
if yyS[yypt-1].item.([]*ast.ResourceGroupOption)[0].Tp == yyS[yypt-0].item.(*ast.ResourceGroupOption).Tp ||
(len(yyS[yypt-1].item.([]*ast.ResourceGroupOption)) > 1 && yyS[yypt-1].item.([]*ast.ResourceGroupOption)[1].Tp == yyS[yypt-0].item.(*ast.ResourceGroupOption).Tp) {
yylex.AppendError(yylex.Errorf("Dupliated options specified"))
return 1
}
parser.yyVAL.item = append(yyS[yypt-1].item.([]*ast.ResourceGroupOption), yyS[yypt-0].item.(*ast.ResourceGroupOption))
}
case 11:
{
parser.yyVAL.item = append(yyS[yypt-2].item.([]*ast.ResourceGroupOption), yyS[yypt-0].item.(*ast.ResourceGroupOption))
if yyS[yypt-2].item.([]*ast.ResourceGroupOption)[0].Tp == yyS[yypt-0].item.(*ast.ResourceGroupOption).Tp {
if yyS[yypt-2].item.([]*ast.ResourceGroupOption)[0].Tp == yyS[yypt-0].item.(*ast.ResourceGroupOption).Tp ||
(len(yyS[yypt-2].item.([]*ast.ResourceGroupOption)) > 1 && yyS[yypt-2].item.([]*ast.ResourceGroupOption)[1].Tp == yyS[yypt-0].item.(*ast.ResourceGroupOption).Tp) {
yylex.AppendError(yylex.Errorf("Dupliated options specified"))
return 1
}
parser.yyVAL.item = append(yyS[yypt-2].item.([]*ast.ResourceGroupOption), yyS[yypt-0].item.(*ast.ResourceGroupOption))
}
case 12:
{
Expand Down
14 changes: 8 additions & 6 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1599,19 +1599,21 @@ ResourceGroupOptionList:
}
| ResourceGroupOptionList DirectResourceGroupOption
{
$$ = append($1.([]*ast.ResourceGroupOption), $2.(*ast.ResourceGroupOption))
if $1.([]*ast.ResourceGroupOption)[0].Tp == $2.(*ast.ResourceGroupOption).Tp {
if $1.([]*ast.ResourceGroupOption)[0].Tp == $2.(*ast.ResourceGroupOption).Tp ||
(len($1.([]*ast.ResourceGroupOption)) > 1 && $1.([]*ast.ResourceGroupOption)[1].Tp == $2.(*ast.ResourceGroupOption).Tp) {
yylex.AppendError(yylex.Errorf("Dupliated options specified"))
return 1
}
$$ = append($1.([]*ast.ResourceGroupOption), $2.(*ast.ResourceGroupOption))
}
| ResourceGroupOptionList ',' DirectResourceGroupOption
{
if $1.([]*ast.ResourceGroupOption)[0].Tp == $3.(*ast.ResourceGroupOption).Tp ||
(len($1.([]*ast.ResourceGroupOption)) > 1 && $1.([]*ast.ResourceGroupOption)[1].Tp == $3.(*ast.ResourceGroupOption).Tp) {
yylex.AppendError(yylex.Errorf("Dupliated options specified"))
return 1
}
$$ = append($1.([]*ast.ResourceGroupOption), $3.(*ast.ResourceGroupOption))
if $1.([]*ast.ResourceGroupOption)[0].Tp == $3.(*ast.ResourceGroupOption).Tp {
yylex.AppendError(yylex.Errorf("Dupliated options specified"))
return 1
}
}

DirectResourceGroupOption:
Expand Down