Repository navigation
Keep the grant option when editing privileges on MySQL 8.0.11+ - #20523
Open
cB-Abhinav-Gautam wants to merge 1 commit into
Open
cB-Abhinav-Gautam wants to merge 1 commit into
cB-Abhinav-Gautam wants to merge 1 commit into
Conversation
Since MySQL 8.0.11, generateQueriesForUpdatePrivileges() moves the WITH clause from the GRANT statement to ALTER USER, and getWithClauseForAddUserAndUpdatePrivs() correctly leaves GRANT OPTION out of it because ALTER USER cannot set it. Nothing put it back on the GRANT, so ticking "Grant" when editing global, database, table or routine privileges silently dropped the grant option. Append WITH GRANT OPTION to the GRANT statement in that case, as the add-user path already does. Refs phpmyadmin#19605 Signed-off-by: Abhinav Gautam <abhinav@codebuckets.in> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YE52bG3MYFauvkA4kmDur
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Since MySQL 8.0.11,
generateQueriesForUpdatePrivileges()moves the WITH clause from the GRANT statement toALTER USER.getWithClauseForAddUserAndUpdatePrivs()correctly leavesGRANT OPTIONout of that clause, becauseALTER USERcannot set it. However, nothing put it back on the GRANT. As a result, ticking "Grant" when editing global, database, table or routine privileges silently dropped the grant option.This change appends
WITH GRANT OPTIONto the GRANT statement in that case, as the add-user path already does. TheALTER USERstatement and the queries for MySQL < 8.0.11 and MariaDB are unchanged.Before (MySQL 8.4, database level, Grant ticked):
After:
Tests
testUpdatePrivilegesAfterMySql8Dot11now expects the grant option. It postsGrant_priv=Yand previously asserted the buggy output.testGenerateQueriesForUpdatePrivilegesKeepsGrantOptionAfterMySql8Dot11covers the database-level case from does not set a GRANT at the database level for a database user #19605.SHOW GRANTSreports... WITH GRANT OPTION.Refs #19605 and the new issue #20521
The same fix is also opened against
QA_5_2.