Skip to content

MsSql: Read one statement as the body of WHILE without BEGIN - #2992

Open
colinhacks wants to merge 3 commits into
apache:mainfrom
colinhacks:mssql-while-single-statement
Open

colinhacks wants to merge 3 commits into
apache:mainfrom
colinhacks:mssql-while-single-statement

Conversation

@colinhacks

Copy link
Copy Markdown

Dialects: MsSql

WHILE @n < 10 SET @n = @n + 1; SELECT @n; parsed into a single While whose body held both the SET and the SELECT: without BEGIN, parse_while read statements up to an END or the end of input. Without the final ; the same input failed with Expected: ;, found: EOF.

T-SQL takes one statement or one BEGIN ... END block there. The body is now parsed as one statement unless BEGIN follows, so the statements after it parse on their own, and a WHILE with no body fails with Expected: an SQL statement, found: EOF. parse_while is shared, so this applies to every dialect; none has a body without BEGIN that runs to END.

A body without BEGIN now displays without a trailing ;, so a WHILE inside a BEGIN ... END list round-trips instead of printing ;;. The WHILE arm of parse_conditional_statement_block, which no caller reached any more, is removed.

Written with an AI coding assistant.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 18:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants