Skip to content

Commit

Permalink
*: Revert "add super privilege check for some admin commands (#51497)" (
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Mar 20, 2024
1 parent ceea10c commit 0299b44
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 53 deletions.
2 changes: 1 addition & 1 deletion pkg/infoschema/test/clustertablestest/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ func TestCapturePrivilege(t *testing.T) {
require.Len(t, rows, 0)
tk1.MustExec("select * from t1 where b=1")
tk1.MustExec("select * from t1 where b=1")
tk.MustExec("admin capture bindings")
tk1.MustExec("admin capture bindings")
rows = tk1.MustQuery("show global bindings").Rows()
require.Len(t, rows, 1)

Expand Down
23 changes: 12 additions & 11 deletions pkg/planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1439,29 +1439,30 @@ func (b *PlanBuilder) buildAdmin(ctx context.Context, as *ast.AdminStmt) (Plan,
p.setSchemaAndNames(buildShowSlowSchema())
ret = p
case ast.AdminReloadExprPushdownBlacklist:
ret = &ReloadExprPushdownBlacklist{}
return &ReloadExprPushdownBlacklist{}, nil
case ast.AdminReloadOptRuleBlacklist:
ret = &ReloadOptRuleBlacklist{}
return &ReloadOptRuleBlacklist{}, nil
case ast.AdminPluginEnable:
ret = &AdminPlugins{Action: Enable, Plugins: as.Plugins}
return &AdminPlugins{Action: Enable, Plugins: as.Plugins}, nil
case ast.AdminPluginDisable:
ret = &AdminPlugins{Action: Disable, Plugins: as.Plugins}
return &AdminPlugins{Action: Disable, Plugins: as.Plugins}, nil
case ast.AdminFlushBindings:
ret = &SQLBindPlan{SQLBindOp: OpFlushBindings}
return &SQLBindPlan{SQLBindOp: OpFlushBindings}, nil
case ast.AdminCaptureBindings:
ret = &SQLBindPlan{SQLBindOp: OpCaptureBindings}
return &SQLBindPlan{SQLBindOp: OpCaptureBindings}, nil
case ast.AdminEvolveBindings:
var err error
// The 'baseline evolution' only work in the test environment before the feature is GA.
if !config.CheckTableBeforeDrop {
return nil, errors.Errorf("Cannot enable baseline evolution feature, it is not generally available now")
err = errors.Errorf("Cannot enable baseline evolution feature, it is not generally available now")
}
ret = &SQLBindPlan{SQLBindOp: OpEvolveBindings}
return &SQLBindPlan{SQLBindOp: OpEvolveBindings}, err
case ast.AdminReloadBindings:
ret = &SQLBindPlan{SQLBindOp: OpReloadBindings}
return &SQLBindPlan{SQLBindOp: OpReloadBindings}, nil
case ast.AdminReloadStatistics:
ret = &Simple{Statement: as}
return &Simple{Statement: as}, nil
case ast.AdminFlushPlanCache:
ret = &Simple{Statement: as}
return &Simple{Statement: as}, nil
case ast.AdminSetBDRRole, ast.AdminUnsetBDRRole:
ret = &Simple{Statement: as}
case ast.AdminShowBDRRole:
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/stmtsummary/v2/tests/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func TestCapturePrivilege(t *testing.T) {
require.Len(t, rows, 0)
tk1.MustExec("select * from t1 where b=1")
tk1.MustExec("select * from t1 where b=1")
tk.MustExec("admin capture bindings")
tk1.MustExec("admin capture bindings")
rows = tk1.MustQuery("show global bindings").Rows()
require.Len(t, rows, 1)

Expand Down
20 changes: 0 additions & 20 deletions tests/integrationtest/r/privilege/privileges.result
Original file line number Diff line number Diff line change
Expand Up @@ -617,23 +617,3 @@ ADMIN SHOW SLOW RECENT 3;
Error 8121 (HY000): privilege check for 'Super' fail
ADMIN SHOW SLOW TOP ALL 3;
Error 8121 (HY000): privilege check for 'Super' fail
admin reload expr_pushdown_blacklist;
Error 8121 (HY000): privilege check for 'Super' fail
admin reload opt_rule_blacklist;
Error 8121 (HY000): privilege check for 'Super' fail
admin plugins enable audit;
Error 8121 (HY000): privilege check for 'Super' fail
admin plugins disable audit;
Error 8121 (HY000): privilege check for 'Super' fail
admin flush bindings;
Error 8121 (HY000): privilege check for 'Super' fail
admin capture bindings;
Error 8121 (HY000): privilege check for 'Super' fail
admin reload bindings;
Error 8121 (HY000): privilege check for 'Super' fail
admin flush session plan_cache;
Error 8121 (HY000): privilege check for 'Super' fail
admin flush global plan_cache;
Error 8121 (HY000): privilege check for 'Super' fail
admin flush instance plan_cache;
Error 8121 (HY000): privilege check for 'Super' fail
20 changes: 0 additions & 20 deletions tests/integrationtest/t/privilege/privileges.test
Original file line number Diff line number Diff line change
Expand Up @@ -841,26 +841,6 @@ ADMIN SHOW privilege__privileges.admin NEXT_ROW_ID;
ADMIN SHOW SLOW RECENT 3;
-- error 8121
ADMIN SHOW SLOW TOP ALL 3;
-- error 8121
admin reload expr_pushdown_blacklist;
-- error 8121
admin reload opt_rule_blacklist;
-- error 8121
admin plugins enable audit;
-- error 8121
admin plugins disable audit;
-- error 8121
admin flush bindings;
-- error 8121
admin capture bindings;
-- error 8121
admin reload bindings;
-- error 8121
admin flush session plan_cache;
-- error 8121
admin flush global plan_cache;
-- error 8121
admin flush instance plan_cache;

disconnect without_super;
connection default;

0 comments on commit 0299b44

Please sign in to comment.