Repository navigation
Limit MySQL discovery to the configured database - #137
Closed
just-some-random-pal wants to merge 1 commit into
Closed
just-some-random-pal wants to merge 1 commit into
just-some-random-pal wants to merge 1 commit into
Conversation
`mysql.database` now scopes schema discovery and schema-based feature detection to one database, as docs/mysql.md already describes. An empty value still discovers every user database. Configuration, performance, replication, and security checks remain server-wide. The configured name is embedded as a hex literal so it stays out of SQL syntax and compares in the column's character set on every supported server. Closes planetscale#124
just-some-random-pal
force-pushed
the
fix/mysql-database-scope
branch
from
October 8, 2026 12:33
bd3e389 to
94a7bc1
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.
mysql.databasenow scopes MySQL discovery the way MySQL Setup already says it does. Before, the setting only chose the connection's default database, and schema discovery scanned every non-system database on the server. Closes #124.What changes:
run_analysispasses{"database": ...}to every MySQL analyzer, so the setting is available where the queries are built.MySQLSchemaAnalyzerreturns the configured database from_get_database_listwithout runningSHOW DATABASES, and everyinformation_schemaquery comparestable_schemato that database instead of excluding the system databases.MySQLFeatureAnalyzerapplies the same filter to its schema-based checks (full-text indexes, spatial columns, foreign keys, partitions, InnoDB compression), so a feature in another database is no longer reported for the configured one.databasekeeps the current server-wide behavior, which the README and config template already describe as "discover all databases".The filter embeds the configured name as a hex literal (
table_schema = 0x6170...) rather than a quoted string. The fragment is spliced into many queries thatexecute_queryruns without parameters, and a hex literal keeps the name out of SQL syntax regardless of the connection's escaping mode. Left as a plain literal it has the same coercibility as the quoted system database names the file already compares againstinformation_schema, so it takes the column's character set on every supported server rather than depending on a utf8mb3/utf8mb4 tie-break. A unit test checks thatapp' OR 1=1reaches the server only as hex.Verification:
test_mysql_discovery.py,test_mysql_schema_analyzer.py, andtest_mysql_feature_analyzer.py. The full suite,black,flake8,mypy, andbanditpass with the CI settings.appdatabase and another_appdatabase that has a full-text index: withdatabase: appthe report lists onlyappindatabase_catalogand every schema list, andfull_text_indexingis false. Withdatabase: ""both databases appear andfull_text_indexingis true.information_schema.schemataand against autf8mb3_general_cicolumn, with the connection inutf8mb4and inutf8mb3.