Skip to content

MsSql: End a RETURN without a value at the next statement keyword - #2993

Draft
colinhacks wants to merge 5 commits into
apache:mainfrom
colinhacks:mssql-return-without-value
Draft

colinhacks wants to merge 5 commits into
apache:mainfrom
colinhacks:mssql-return-without-value

Conversation

@colinhacks

Copy link
Copy Markdown

Dialects: MsSql

A RETURN with no value read the keyword after it as a column name. IF @f = 1 BEGIN RETURN END failed with Expected: END, found: EOF, and with require_semicolon_stmt_delimiter = false, IF @f = 1 RETURN followed by SELECT id FROM t on the next line failed with Expected: an SQL statement, found: id.

MsSql now parses RETURN itself and gives it no value when the next token is a keyword that cannot be an implicit alias, such as SELECT, SET, IF or END, following the check suggested in #1949 (comment). Values such as @x, @@ERROR, SYSTEM_USER, (SELECT 1), function calls and CASE read as before, and other dialects keep the generic RETURN.

This builds on #2991, which adds SET, BEGIN and the other statement keywords to the list the check reads, and its commits come first here until it merges.

Refs #1800

Written with an AI coding assistant.

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.

1 participant