Repository navigation
MsSql: Accept statements without semicolons in BEGIN ... END blocks - #2994
Open
colinhacks wants to merge 2 commits into
Open
colinhacks wants to merge 2 commits into
colinhacks wants to merge 2 commits into
Conversation
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.
Dialects: MsSql, Generic
With
require_semicolon_stmt_delimiter = false, statements at the top level of a batch need no;, but statements inside aBEGIN ... ENDblock, aWHILEbody, or a procedure, function or trigger body still did.BEGIN SELECT 1 SELECT 2 ENDfailed withExpected: ;, found: SELECT, andWHILE @i < 3 BEGIN SET @i = @i + 1; SELECT @i ENDwithExpected: ;, found: END. T-SQL makes the semicolon optional in both places (https://learn.microsoft.com/en-us/sql/t-sql/language-elements/transact-sql-syntax-conventions-transact-sql).parse_statement_listnow skips any;before and after each statement when the option is off, asparse_statementsdoes at the top level. With the default options a;is still required after each statement. The same change was part of #1949.Not covered: with the option off, a keyword that ends a block can still be read as an implicit alias in dialects that accept it as one, as statement keywords can be at the top level today, e.g.
ELSEin Generic'sIF x THEN SELECT a FROM t ELSE .... For MsSql, statement keywords read as implicit aliases are #2991, and aWHILEwithoutBEGINtaking the statements after it is #2992.Refs #1800
Written with an AI coding assistant.