fix: parse MySQL simple-form CREATE FUNCTION in multi-statement scripts - #6707
Open
kalayciburak wants to merge 1 commit into
Open
fix: parse MySQL simple-form CREATE FUNCTION in multi-statement scripts#6707kalayciburak wants to merge 1 commit into
kalayciburak wants to merge 1 commit into
Conversation
Simple-form CREATE FUNCTION (RETURN expr without BEGIN...END) consumed the trailing semicolon on the body and then treated leftover tokens as an unexpected end of the function. A following SELECT or CREATE in the same script therefore failed to parse. Parse the body without requiring end-of-script, and treat a terminator on the function body as completing the CREATE statement. Fixes alibaba#6705
|
|
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.
What is wrong
MySQL simple-form
CREATE FUNCTION(body isRETURN exprwithoutBEGIN...END) failed to parse when another statement followed in the same script:BEGIN...ENDbodies were already fine.The function body was parsed with
parseStatement(), which treats leftover tokens as an unexpected end of the statement. The trailing semicolon was also consumed on theRETURNbody, so the outer statement list did not see a terminator on theCREATE FUNCTIONitself.How this PR fixes it
parseStatement0()so a following statement in the same script is left for the caller.CREATEas complete inparseStatementList.Fixes #6705
Tests
Executed:
Results: Tests run: 10, Failures: 0, Errors: 0, Skipped: 0
Also
mvn test -pl core -Dtest=*CreateFunction*(same 10 tests) and checkstyle: 0 violations.