Repository navigation
fix(mysql): say which grant is missing when a routine's body is hidden - #290
Merged
Merged
Conversation
MySQL lists a routine to any user with privileges on its schema but shows its body only to its definer or a user with SHOW_ROUTINE; everyone else gets NULL from SHOW CREATE PROCEDURE/FUNCTION. getRoutines passed that NULL on and the diff died with a TypeError. It now stops with a message naming the routine and the grant. Skipping the routine instead would make it read as dropped and put a DROP in the migration. Fixes #286 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sonar caps a class at 20 methods; the helper made MySQLAdapter 21. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.



Fixes #286
What was wrong
On MySQL, a user with every privilege on a schema can see its routines listed in
information_schema.ROUTINES. It still can't see their bodies unless it defined them or holdsSHOW_ROUTINE(MySQL 8.0.20+) or globalSELECT. For anyone else,SHOW CREATE PROCEDURE/SHOW CREATE FUNCTIONreturns the row with a NULL definition rather than an error.MySQLAdapter::getRoutines()passed that NULL tonormalizeCreateStatement(), so the diff died with aTypeError.Reproduced on MySQL 8.4 with a user granted
ALL PRIVILEGES ON app.*:SHOW CREATE TRIGGERandSHOW CREATE EVENTreturn their definitions, so only routines are affected.MariaDB (11.4) returns the definition to the same user, so it is unaffected. PostgreSQL and SQLite don't use this path.
The fix
getRoutines()now stops with aDBException. The message names the routine and the grant that fixes it (GRANT SHOW_ROUTINE ON *.* TO <user>), or suggests connecting as the routine's definer.Skipping the unreadable routine instead would be unsafe. On the source side the routine would read as missing, and the migration would drop it from the target.
Tests
tests/Unit/MySQLRoutinePrivilegeTest.phpfeedsgetRoutines()the rows MySQL 8.4 returns to such a user.TypeError.Unit suite: 1103 tests, OK.
🤖 Generated with Claude Code