feat(tidb): add schema introspection tools and prebuilt config#2949
feat(tidb): add schema introspection tools and prebuilt config#2949qiffang wants to merge 4 commits intogoogleapis:mainfrom
Conversation
Add 4 new TiDB-specific tools to achieve feature parity with MySQL: - tidb-list-tables: List table schema info with TiFlash replica count - tidb-get-query-plan: EXPLAIN with safety checks (ANALYZE restricted to SELECT) - tidb-list-active-queries: Show running queries from processlist - tidb-list-tiflash-replicas: TiDB-specific tool for TiFlash replica status Add prebuilt config (tidb.yaml) with toolsets: data, monitor, htap Security features: - EXPLAIN ANALYZE restricted to SELECT/WITH statements only - Multi-statement injection prevention (semicolon detection) - SQL comment stripping for accurate statement type detection - TiDB version compatibility check using MySQL error code 1054 Known limitations (tracked for follow-up): - containsMultipleStatements() does not handle backticks or escaped quotes Tested with TiDB 4.0+ and TiDB Cloud.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request implements TiDB support by adding tools for query planning, active query monitoring, table metadata listing, and TiFlash replica status, along with a prebuilt configuration and unit tests. The review feedback suggests enhancing the multi-statement SQL detection by stripping comments before validation to avoid false positives and simplifying parameter type assertions to align with established repository patterns.
1. containsMultipleStatements: strip comments before checking for semicolons to avoid false positives (e.g., SELECT 1 -- comment;) 2. limit parameter: simplify type assertion as framework guarantees type safety for typed constructors like NewIntParameterWithDefault Added test cases for semicolons in comments.
Only my new files should have copyright year 2026.
|
Hi @qiffang, thank you for the contribution! We recently renamed the repository, which updated the package name. Could you please rebase your branch against the latest main before we dive into the review? It’ll help avoid any import issues. Thanks |
Description
This PR adds 4 new TiDB-specific tools to achieve feature parity with MySQL, plus a prebuilt config for one-command startup.
New Tools
tidb-list-tablestidb-get-query-plantidb-list-active-queriestidb-list-tiflash-replicasPrebuilt Config
internal/prebuiltconfigs/tools/tidb.yamlenables--prebuilt=tidbwith three toolsets:Security Features
--and/* */comments for accurate statement type detectionKnown Limitations
containsMultipleStatements()does not handle:These are tracked for follow-up improvement.
Testing
Related
Builds on the existing TiDB source and basic tools contributed by @Icemap in #829.