MSSQL: support EXEC (@sql) dynamic SQL execution#2234
Merged
yoavcloud merged 1 commit intoapache:mainfrom Feb 27, 2026
Merged
Conversation
2b64f60 to
8bfd2af
Compare
yoavcloud
approved these changes
Feb 27, 2026
parse_execute() was consuming a second parameter list after already parsing the parenthesised name expression, causing parse failures on any token that immediately followed EXEC (@SQL). Fixed by tracking whether the name was itself wrapped in parens; when it is, skip the parameter-list scan and leave no tokens consumed for the caller to mis-interpret. Adds test_exec_dynamic_sql covering both the standalone form and the case where a subsequent statement follows on the next line.
8bfd2af to
928eb66
Compare
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.
Problem
EXEC (@sql)— the T-SQL form for executing a dynamically-built SQL string — was failing to parse.parse_execute()was consuming a second parameter list after already parsing the parenthesised name expression, causing parse failures on any token that immediately followed.Fix
Track whether the name expression was itself wrapped in parens. When it is (
EXEC (@sql)), skip the parameter-list scan so no extra tokens are consumed.Test
Adds
test_exec_dynamic_sqlcovering:EXEC (@sql)standaloneEXEC (@sql)followed by another statement on the next line