Repository navigation
Fix ALTER DATABASE without a database name - #693
Open
kamil-tekiela wants to merge 1 commit into
Open
kamil-tekiela wants to merge 1 commit into
kamil-tekiela wants to merge 1 commit into
Conversation
MySQL allows `ALTER DATABASE alter_option ...` without a name; it changes the default database. AlterStatement::parse() always skipped the token after the name, so without a name it skipped the first token of the alter operation: `ALTER DATABASE CHARACTER SET utf8mb4` gave the operation `utf8mb4` and the error "Unrecognized alter operation.". AlterStatement::build() then called Expression::build() with null. Skip the token only when a name was parsed, and leave the name out of build() when there is none. The parseAlter2 fixture changes because its name is the unquoted reserved word `table`, which is not parsed as a name: the `CONVERT` option of the operation is now kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kamil Tekiela <tekiela246@gmail.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.
MySQL allows
ALTER {DATABASE | SCHEMA} [db_name] alter_option .... Without a name, the statement changes the default database.AlterStatement::parse()always skipped the token after the name. Without a name, it skipped the first token of the alter operation:ALTER DATABASE CHARACTER SET utf8mb4utf8mb4, error "Unrecognized alter operation."CHARACTER SET utf8mb4, no errorsALTER DATABASE DEFAULT CHARACTER SET utf8mb4utf8mb4, errorDEFAULT CHARACTER SET utf8mb4, no errorsbuild()then passednulltoExpression::build(). On 5.11.x this gives "Attempt to read property "expr" on null" warnings; on 6.0.x and master$this->table->build()throws anError.Changes
build()when there is none. This removes a PHPStan baseline entry.parseAlter2fixture changes. Its name is the unquoted reserved wordtable, which is not parsed as a name, so its first token was skipped too. The operation now keeps itsCONVERToption. The errors stay the same.When merging up to 6.0.x, the
build()line there is. ' ' . $this->table->build(). It needs the same null check.ALTER SCHEMAis still not supported, becauseSCHEMAis missing fromAlterStatement::$statementOptions. I left it out of this PR.🤖 Generated with Claude Code