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: scope search_objects to configured database on MySQL/MariaDB (#332)
* 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>
* fix: scope search_objects to configured database on MySQL/MariaDB
search_objects without an explicit schema fanned out over
connector.getSchemas(), which on MySQL/MariaDB returns every database
on the server (INFORMATION_SCHEMA.SCHEMATA). This leaked tables, views,
columns, procedures, and indexes from databases the user never
configured, and made object_type="schema" list the whole instance.
Introduce an optional Connector.getDefaultSchema() returning the schema
a search should default to (the DSN database via DATABASE() on
MySQL/MariaDB, or null when none is configured). The tool layer now
resolves the search scope as: explicit schema -> connector default ->
full getSchemas() list. Validation of an explicit schema still uses the
full list, so deliberate cross-database access is preserved.
Also exclude system databases (information_schema, performance_schema,
mysql, sys) from getSchemas() on MySQL/MariaDB, matching the PostgreSQL
connector which already hides pg_catalog et al. Connectors whose
getSchemas() is already scoped to the connected database (PostgreSQL,
SQL Server, SQLite) need no change.
Fixes#323
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