pingcap/tidb

'show stats_meta' requires the whole mysql db privilege

Open

#27.941 aperta il 10 set 2021

Vedi su GitHub
 (3 commenti) (1 reazione) (1 assegnatario)Go (6186 fork)batch import
help wantedsig/sql-infratype/question

Metriche repository

Star
 (40.090 star)
Metriche merge PR
 (Merge medio 14g 4h) (346 PR mergiate in 30 g)

Descrizione

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create a user with mysql.stats_meta table select privilege granted

show stats_meta

2. What did you expect to see? (Required)

I think the user should be able to execute show stats_meta

3. What did you see instead (Required)

privilege check failed, it requires the whole mysql db privilege.

The bug is in planner/core/planbuilder.go, see:

case ast.ShowStatsBuckets, ast.ShowStatsHistograms, ast.ShowStatsMeta, ast.ShowStatsExtended, ast.ShowStatsHealthy, ast.ShowStatsTopN:
		user := b.ctx.GetSessionVars().User
		var err error
		if user != nil {
			err = ErrDBaccessDenied.GenWithStackByArgs(user.AuthUsername, user.AuthHostname, mysql.SystemDB)
		}
		b.visitInfo = appendVisitInfo(b.visitInfo, mysql.SelectPriv, mysql.SystemDB, "", "", err)

4. What is your TiDB version? (Required)

mysql> select tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                           |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.3.0-alpha-58-g8f642929e
Edition: Community
Git Commit Hash: 8f642929e04cf35c982314c576b71bedf57d9f22
Git Branch: master
UTC Build Time: 2021-09-10 01:17:12
GoVersion: go1.16.7
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Guida contributor