Skip to content

Commit bdc64e5

Browse files
authored
*: Revert "add super privilege check for some admin commands (#51497)" (#51938)
close #51936
1 parent 1b7a41d commit bdc64e5

File tree

5 files changed

+14
-53
lines changed

5 files changed

+14
-53
lines changed

pkg/infoschema/test/clustertablestest/tables_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ func TestCapturePrivilege(t *testing.T) {
977977
require.Len(t, rows, 0)
978978
tk1.MustExec("select * from t1 where b=1")
979979
tk1.MustExec("select * from t1 where b=1")
980-
tk.MustExec("admin capture bindings")
980+
tk1.MustExec("admin capture bindings")
981981
rows = tk1.MustQuery("show global bindings").Rows()
982982
require.Len(t, rows, 1)
983983

pkg/planner/core/planbuilder.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,29 +1439,30 @@ func (b *PlanBuilder) buildAdmin(ctx context.Context, as *ast.AdminStmt) (Plan,
14391439
p.setSchemaAndNames(buildShowSlowSchema())
14401440
ret = p
14411441
case ast.AdminReloadExprPushdownBlacklist:
1442-
ret = &ReloadExprPushdownBlacklist{}
1442+
return &ReloadExprPushdownBlacklist{}, nil
14431443
case ast.AdminReloadOptRuleBlacklist:
1444-
ret = &ReloadOptRuleBlacklist{}
1444+
return &ReloadOptRuleBlacklist{}, nil
14451445
case ast.AdminPluginEnable:
1446-
ret = &AdminPlugins{Action: Enable, Plugins: as.Plugins}
1446+
return &AdminPlugins{Action: Enable, Plugins: as.Plugins}, nil
14471447
case ast.AdminPluginDisable:
1448-
ret = &AdminPlugins{Action: Disable, Plugins: as.Plugins}
1448+
return &AdminPlugins{Action: Disable, Plugins: as.Plugins}, nil
14491449
case ast.AdminFlushBindings:
1450-
ret = &SQLBindPlan{SQLBindOp: OpFlushBindings}
1450+
return &SQLBindPlan{SQLBindOp: OpFlushBindings}, nil
14511451
case ast.AdminCaptureBindings:
1452-
ret = &SQLBindPlan{SQLBindOp: OpCaptureBindings}
1452+
return &SQLBindPlan{SQLBindOp: OpCaptureBindings}, nil
14531453
case ast.AdminEvolveBindings:
1454+
var err error
14541455
// The 'baseline evolution' only work in the test environment before the feature is GA.
14551456
if !config.CheckTableBeforeDrop {
1456-
return nil, errors.Errorf("Cannot enable baseline evolution feature, it is not generally available now")
1457+
err = errors.Errorf("Cannot enable baseline evolution feature, it is not generally available now")
14571458
}
1458-
ret = &SQLBindPlan{SQLBindOp: OpEvolveBindings}
1459+
return &SQLBindPlan{SQLBindOp: OpEvolveBindings}, err
14591460
case ast.AdminReloadBindings:
1460-
ret = &SQLBindPlan{SQLBindOp: OpReloadBindings}
1461+
return &SQLBindPlan{SQLBindOp: OpReloadBindings}, nil
14611462
case ast.AdminReloadStatistics:
1462-
ret = &Simple{Statement: as}
1463+
return &Simple{Statement: as}, nil
14631464
case ast.AdminFlushPlanCache:
1464-
ret = &Simple{Statement: as}
1465+
return &Simple{Statement: as}, nil
14651466
case ast.AdminSetBDRRole, ast.AdminUnsetBDRRole:
14661467
ret = &Simple{Statement: as}
14671468
case ast.AdminShowBDRRole:

pkg/util/stmtsummary/v2/tests/table_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func TestCapturePrivilege(t *testing.T) {
306306
require.Len(t, rows, 0)
307307
tk1.MustExec("select * from t1 where b=1")
308308
tk1.MustExec("select * from t1 where b=1")
309-
tk.MustExec("admin capture bindings")
309+
tk1.MustExec("admin capture bindings")
310310
rows = tk1.MustQuery("show global bindings").Rows()
311311
require.Len(t, rows, 1)
312312

tests/integrationtest/r/privilege/privileges.result

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -617,23 +617,3 @@ ADMIN SHOW SLOW RECENT 3;
617617
Error 8121 (HY000): privilege check for 'Super' fail
618618
ADMIN SHOW SLOW TOP ALL 3;
619619
Error 8121 (HY000): privilege check for 'Super' fail
620-
admin reload expr_pushdown_blacklist;
621-
Error 8121 (HY000): privilege check for 'Super' fail
622-
admin reload opt_rule_blacklist;
623-
Error 8121 (HY000): privilege check for 'Super' fail
624-
admin plugins enable audit;
625-
Error 8121 (HY000): privilege check for 'Super' fail
626-
admin plugins disable audit;
627-
Error 8121 (HY000): privilege check for 'Super' fail
628-
admin flush bindings;
629-
Error 8121 (HY000): privilege check for 'Super' fail
630-
admin capture bindings;
631-
Error 8121 (HY000): privilege check for 'Super' fail
632-
admin reload bindings;
633-
Error 8121 (HY000): privilege check for 'Super' fail
634-
admin flush session plan_cache;
635-
Error 8121 (HY000): privilege check for 'Super' fail
636-
admin flush global plan_cache;
637-
Error 8121 (HY000): privilege check for 'Super' fail
638-
admin flush instance plan_cache;
639-
Error 8121 (HY000): privilege check for 'Super' fail

tests/integrationtest/t/privilege/privileges.test

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -841,26 +841,6 @@ ADMIN SHOW privilege__privileges.admin NEXT_ROW_ID;
841841
ADMIN SHOW SLOW RECENT 3;
842842
-- error 8121
843843
ADMIN SHOW SLOW TOP ALL 3;
844-
-- error 8121
845-
admin reload expr_pushdown_blacklist;
846-
-- error 8121
847-
admin reload opt_rule_blacklist;
848-
-- error 8121
849-
admin plugins enable audit;
850-
-- error 8121
851-
admin plugins disable audit;
852-
-- error 8121
853-
admin flush bindings;
854-
-- error 8121
855-
admin capture bindings;
856-
-- error 8121
857-
admin reload bindings;
858-
-- error 8121
859-
admin flush session plan_cache;
860-
-- error 8121
861-
admin flush global plan_cache;
862-
-- error 8121
863-
admin flush instance plan_cache;
864844

865845
disconnect without_super;
866846
connection default;

0 commit comments

Comments
 (0)