Bug #99707 EXPLAIN requires more than SELECT
Submitted: 27 May 2020 12:33 Modified: 1 Jun 2020 11:42
Reporter: Francisco Miguel Biete Banon Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:8.0.20, 5.7.30 OS:Any
Assigned to: CPU Architecture:Any
Tags: explain, privileges

[27 May 2020 12:33] Francisco Miguel Biete Banon
Description:
EXPLAIN documentation is incorrect:

From v8 documentation
```
EXPLAIN requires the SELECT privilege for any tables or views accessed, including any underlying tables of views. For views, EXPLAIN also requires the SHOW VIEW privilege. EXPLAIN ... FOR CONNECTION additionally requires the PROCESS privilege if the specified connection belongs to a different user.
```

https://dev.mysql.com/doc/refman/8.0/en/explain.html

That's not correct.

EXPLAIN requires the same privileges that the operation trying to explain would require. For example, running EXPLAIN for a DELETE would require DELETE...

How to repeat:
Try to EXPLAIN INSERT/UPDATE/DELETE with an account with SELECT only

Suggested fix:
If the documentation is correct, then SELECT should be enough to explain INSERT/DELETE/UPDATE...

If the documentation is not correct, then it should be updated.
[27 May 2020 13:21] MySQL Verification Team
Hi Mr. Banon,

Thank you for your documentation enhancement request.

I think that your analysis is correct.

Verified as reported.
[1 Jun 2020 11:42] Paul DuBois
Posted by developer:
 
Revised to:

EXPLAIN requires the same privileges required to execute the explained statement. Additionally, EXPLAIN also requires the SHOW VIEW privilege for any explained view. EXPLAIN ... FOR CONNECTION also requires the PROCESS privilege if the specified connection belongs to a different user.
[1 Jun 2020 12:29] MySQL Verification Team
Thank you, Paul.