Skip to content

MSSQL: support EXEC (@sql) dynamic SQL execution#2234

Merged
yoavcloud merged 1 commit intoapache:mainfrom
yoabot-droid:mssql-exec-dynamic-sql
Feb 27, 2026
Merged

MSSQL: support EXEC (@sql) dynamic SQL execution#2234
yoavcloud merged 1 commit intoapache:mainfrom
yoabot-droid:mssql-exec-dynamic-sql

Conversation

@yoabot-droid
Copy link
Contributor

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_sql covering:

  • EXEC (@sql) standalone
  • EXEC (@sql) followed by another statement on the next line

@yoabot-droid yoabot-droid force-pushed the mssql-exec-dynamic-sql branch from 2b64f60 to 8bfd2af Compare February 26, 2026 12:54
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.
@yoavcloud yoavcloud force-pushed the mssql-exec-dynamic-sql branch from 8bfd2af to 928eb66 Compare February 27, 2026 10:41
@yoavcloud yoavcloud enabled auto-merge February 27, 2026 10:42
@yoavcloud yoavcloud added this pull request to the merge queue Feb 27, 2026
Merged via the queue into apache:main with commit 6f0e803 Feb 27, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants