You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: enable query plans on SQL Server via EXPLAIN (#331)
* Fix: enable query plans on SQL Server via EXPLAIN
SQL Server has no native EXPLAIN statement, and the bogus `explain`/
`showplan` entries in the read-only allow-list did nothing. The actual
mechanism, SET SHOWPLAN_XML ON, is session scoped, must be the only
statement in its batch, and is suppressed inside a transaction — so it
could not be used through the pooled, stateless connector.
Translate a leading `EXPLAIN <query>` into a SHOWPLAN_XML request run on
a short-lived single-connection pool, giving SQL Server a Postgres/MySQL
-like EXPLAIN. SHOWPLAN_XML compiles without executing, so it is
read-only safe; the isolated session keeps SHOWPLAN state off the shared
pool. Drop the dead `showplan` keyword.
Closes#310
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Harden SQL Server EXPLAIN translation (PR review)
Address Copilot review feedback on the EXPLAIN/SHOWPLAN flow:
- Skip leading whitespace and SQL comments when detecting EXPLAIN, so a
comment-prefixed EXPLAIN that passes the (comment-stripping) read-only
validator is also translated instead of reaching the server untranslated.
- Trim the extracted inner query.
- Reject empty EXPLAIN and any SET SHOWPLAN inside the explained statement.
SQL Server already blocks SET SHOWPLAN alongside other statements in a
batch (verified: the DELETE does not execute), but this keeps the
read-only guarantee self-contained rather than relying on server behavior.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Treat comment-only EXPLAIN as empty (PR review)
Validate the explained statement against comment/string-stripped SQL so
`EXPLAIN /* comment */` raises the "requires a statement" error instead
of running an empty batch. Reuses the strip already done for the SET
SHOWPLAN guard.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments