feat(plugins): list every schema's tables in one query on SQL Server and DuckDB - #3096
Merged
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
…-listing-plugins # Conflicts: # CHANGELOG.md
This branch was successfully deployed
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.
What changed
SQL Server and DuckDB now answer
fetchTablesInAllSchemas()(#3060) with one query. Open Quickly and the sidebar filter get every other schema's tables in one round trip instead of one per schema. Oracle and Snowflake stay on the per-schema fallback, for the measured and documented reasons under Left on the fallback.One PR rather than one per engine: both engines follow the same pattern and share the Open Quickly docs table and the CHANGELOG, which a PR per engine would each have had to rebase over.
Query shape
This follows the PostgreSQL shape. The per-schema listing becomes a builder over a scope (
.schema/.allSchemas). The all-schema form is the same statement with the schema predicate replaced byIN (<the query fetchSchemas() runs>), plus the schema as a projected column. So a table is listed exactly when its schema is onefetchSchemas()returns, with the same object kinds, exclusions and privilege semantics.MSSQLSchemaQueries.tables(in:)in TableProMSSQLCore. SQL Server rejectsORDER BYin a subquery, so the schema list is split intolistedSchemaNames(unordered) andschemas(that list plusORDER BY SCHEMA_NAME). The plugin'sfetchTablesandfetchSchemaseach inlined their own copy of these two queries. They now use the package's, so the listing, the schema list and the all-schema form come from one place, andparseTableRowreads the optional schema column. The iOS driver's calls (tables(schema:),schemas,parseTableRow) keep their signatures.DuckDBSchemaQueries.listTables(in:)..allSchemasbinds only the catalog ($1, reused inside the subquery) and filters bylistSchemas. A remote Quack connection returnsnil: itsfetchSchemas()is best-effort and falls back tomain, which one filtered query cannot reproduce.System schemas work as they do on PostgreSQL. The host drops rows whose schema is in the engine's
systemSchemaNamesfrom a single-call answer, just as it drops those schemas before the per-schema fallback. SQL Server's schema list already leaves outsys,INFORMATION_SCHEMA, thedb_*role schemas andguest, so those never reach the host. DuckDB's system catalogs are never the current catalog.Parity evidence
scripts/check-mssql-table-listing-parity.shbuilds a fixture with a view, an empty schema, mixed-case and dotted names, a schema where the reader holds a grant on one table only, and tables in thedb_datareaderandguestschemas the schema list excludes. It prints the real queries from TableProMSSQLCore, then diffs the per-schema union against the single query assaand as a SELECT-only login, under the default collation and underLatin1_General_CS_AS. Azure SQL Edge 15.0.2000.1574 (ARM64): PASS, 7 objects assaand 6 as the reader, in both collations. With the filter swapped forTABLE_SCHEMA IS NOT NULLit fails, because the role and guest schemas' tables show up.scripts/check-duckdb-table-listing-parity.shcompiles the realDuckDBPluginDriveragainstLibs/libduckdb.a(v1.5.2). It comparesfetchTables(schema:)overfetchSchemas()withfetchTablesInAllSchemas()in two attached catalogs: asalesschema in both, a temp table, and mixed-case and dotted names. PASS, with 6 and 2 objects. With the filter swapped forschema_name <> 'dot.ted'it fails.scripts/check-duckdb-offline-metadata.shnow compilesDuckDBSchemaQueries.swiftto print both listing forms. The listing is no longer a string constant its extractor can see. Both forms run with no extensions available.Timing
Each range spans two runs on a machine running other builds.
Left on the fallback
SHOW TERSE OBJECTS IN SCHEMA. The database-wide form isSHOW TERSE OBJECTS IN DATABASE, but aSHOWreturns at most 10,000 records (SHOW OBJECTS usage notes). That cap applies per schema on one side and per database on the other, so a database with more than 10,000 objects would silently lose tables from the search. There is no server here to measure anINFORMATION_SCHEMAalternative, and switching the sidebar's listing to one untested is not this change.Tests and verification
TableProMSSQLCoreTests(swift test): PASS, 36 cases inMSSQLSchemaQueriesTests. There are four new cases: the one-schema listing, the all-schema listing filtered by the unordered schema list,schemasas that list plus its ordering, andparseTableRowreading the schema column.TableProTests:DuckDBSchemaQueriesTests,IndexStatementRenderingTestsandCatalogTableListingTestsPASS, 53 of 53 cases.DuckDBSchemaQueriesTestsgains two cases, and its table-list case now runs over both scopes.verify.sh buildPASS,plugins(AllPlugins) PASS, lint clean on the six Swift files,docsPASS, andshellcheck --severity=warningclean.TableProPluginKitVersionis 33 in the MSSQL and DuckDBInfo.plists, equal tocurrentPluginKitVersion.DuckDBPlugin.swift, and a blank line before a closing brace inMSSQLPluginDriver+Schema.swift.Review: a
feature-dev:code-revieweragent, since Codex is unavailable until Sep 29. It found no correctness bugs. Its one finding, that Oracle had no parity script, no longer applies now that Oracle stays on the fallback.Follow-up to #3060 (#3048).