From 0299b449e7e5d734013423ebc35faa8df40ac136 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Wed, 20 Mar 2024 17:21:43 +0800 Subject: [PATCH] *: Revert "add super privilege check for some admin commands (#51497)" (#51938) (#51945) close pingcap/tidb#51936 --- .../test/clustertablestest/tables_test.go | 2 +- pkg/planner/core/planbuilder.go | 23 ++++++++++--------- pkg/util/stmtsummary/v2/tests/table_test.go | 2 +- .../r/privilege/privileges.result | 20 ---------------- .../t/privilege/privileges.test | 20 ---------------- 5 files changed, 14 insertions(+), 53 deletions(-) diff --git a/pkg/infoschema/test/clustertablestest/tables_test.go b/pkg/infoschema/test/clustertablestest/tables_test.go index dc9e8470ced42..03cabd5aa4ff9 100644 --- a/pkg/infoschema/test/clustertablestest/tables_test.go +++ b/pkg/infoschema/test/clustertablestest/tables_test.go @@ -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) diff --git a/pkg/planner/core/planbuilder.go b/pkg/planner/core/planbuilder.go index d66770a6fe74d..c1083b61847c7 100644 --- a/pkg/planner/core/planbuilder.go +++ b/pkg/planner/core/planbuilder.go @@ -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: diff --git a/pkg/util/stmtsummary/v2/tests/table_test.go b/pkg/util/stmtsummary/v2/tests/table_test.go index 71e65864e3995..53acaae838bc6 100644 --- a/pkg/util/stmtsummary/v2/tests/table_test.go +++ b/pkg/util/stmtsummary/v2/tests/table_test.go @@ -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) diff --git a/tests/integrationtest/r/privilege/privileges.result b/tests/integrationtest/r/privilege/privileges.result index 468db0993d4d4..d8b48e13d0ec3 100644 --- a/tests/integrationtest/r/privilege/privileges.result +++ b/tests/integrationtest/r/privilege/privileges.result @@ -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 diff --git a/tests/integrationtest/t/privilege/privileges.test b/tests/integrationtest/t/privilege/privileges.test index 6cdfacaef90c5..7815e14a09585 100644 --- a/tests/integrationtest/t/privilege/privileges.test +++ b/tests/integrationtest/t/privilege/privileges.test @@ -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;